Filter uncanny-automator

uap_option_peepso_users_profile_fields

Filters PeepSo user profile fields to allow modification of displayed fields on user profiles.

add_filter( 'uap_option_peepso_users_profile_fields', $callback, 10, 1 );

Description

This filter hook allows developers to modify the profile fields displayed for users in the PeepSo integration. It fires when PeepSo profile fields are being prepared, enabling customization of field labels, input types, required status, and available options. Use this to add, remove, or alter default PeepSo profile fields for Ultimate Affiliate Pro users.


Usage

add_filter( 'uap_option_peepso_users_profile_fields', 'your_function_name', 10, 1 );

Parameters

$option (mixed)
This parameter contains the existing options for PeepSo profile fields, which can be modified by the filter.

Return Value

The filtered value.


Examples

add_filter( 'uap_option_peepso_users_profile_fields', 'my_custom_peepso_profile_fields', 10, 1 );

/**
 * Adds a custom field to the PeepSo user profile integration with Ultimate Affiliate Pro.
 *
 * This function demonstrates how to modify the array of profile fields
 * managed by the Ultimate Affiliate Pro plugin when integrating with PeepSo.
 * It specifically targets the 'uap_option_peepso_users_profile_fields' filter.
 *
 * @param array $option The array of profile field configurations.
 * @return array The modified array of profile field configurations.
 */
function my_custom_peepso_profile_fields( $option ) {
	// Example: Add a new custom field for "Favorite Color".
	// This assumes the original $option array already contains valid configurations.

	// Check if the current field being processed is one we want to modify or add to.
	// In a real-world scenario, you might check $option['name'] or other keys
	// to target specific existing fields or to decide where to insert a new one.
	// For this example, we'll assume we are adding a new field.

	$new_field_config = array(
		'name'            => 'favorite_color', // Unique name for the field
		'label'           => __( 'Favorite Color', 'your-text-domain' ), // User-facing label
		'input_type'      => 'select', // Type of input field
		'required'        => false, // Whether the field is mandatory
		'options'         => array( // Options for the select dropdown
			''              => __( 'Select a color', 'your-text-domain' ),
			'red'           => __( 'Red', 'your-text-domain' ),
			'blue'          => __( 'Blue', 'your-text-domain' ),
			'green'         => __( 'Green', 'your-text-domain' ),
			'yellow'        => __( 'Yellow', 'your-text-domain' ),
		),
		'relevant_tokens' => array(), // Tokens related to this field if any
		'display_type'    => 'standard', // How the field should be displayed
	);

	// You can either:
	// 1. Append the new field to the existing array:
	$option[] = $new_field_config;

	// 2. Prepend the new field:
	// array_unshift( $option, $new_field_config );

	// 3. Insert it at a specific position (e.g., after an existing 'display_name' field):
	// Find the index of 'display_name' and insert after it.
	/*
	$display_name_index = array_search( 'display_name', array_column( $option, 'name' ) );
	if ( $display_name_index !== false ) {
		array_splice( $option, $display_name_index + 1, 0, array( $new_field_config ) );
	} else {
		// Fallback if 'display_name' is not found
		$option[] = $new_field_config;
	}
	*/

	// Modify an existing field's options or label (example: changing 'required' for a field named 'website')
	/*
	foreach ( $option as &$field ) {
		if ( $field['name'] === 'website' ) {
			$field['required'] = true;
			$field['label'] = __( 'Your Official Website', 'your-text-domain' );
			break; // Exit loop once found
		}
	}
	unset( $field ); // Unset the reference
	*/

	// Return the modified array.
	return $option;
}

Placement

This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.


Source Code

src/integrations/peepso/helpers/peepso-helpers.php:232

public function get_profile_fields( $label = null, $option_code = 'PPPROFILEFIELDS', $args = array(), $bynames = false ) {


		if ( ! $label ) {
			$label = esc_attr__( 'Profile fields', 'uncanny-automator' );
		}

		$args = wp_parse_args(
			$args,
			array(
				'uo_include_any' => ( true === $args['uo_include_any'] ) ? true : false,
				'uo_any_label'   => esc_attr__( 'Any field', 'uncanny-automator' ),
			)
		);

		$options = array();
		$options = $this->get_user_fields( 0, $args['uo_include_any'], $args );

		$option = array(
			'option_code'     => $option_code,
			'label'           => $label,
			'input_type'      => 'select',
			'required'        => true,
			'options'         => $options,
			'relevant_tokens' => array(),
		);

		return apply_filters( 'uap_option_peepso_users_profile_fields', $option );
	}

Scroll to Top