Filter
uncanny-automator
uap_option_peepso_all_users
Filters all user data retrieved by PeepSo before it's displayed or processed.
add_filter( 'uap_option_peepso_all_users', $callback, 10, 1 );
Description
This filter allows developers to modify the options array for the 'Peepso All Users' setting within the Ultimate Affiliate Pro plugin. It fires when the plugin retrieves options related to Peepso user selection, enabling customization of the available choices or their properties before they are displayed.
Usage
add_filter( 'uap_option_peepso_all_users', 'your_function_name', 10, 1 );
Parameters
-
$option(mixed) - This parameter represents the option array being filtered, which is used to retrieve PeepSo users.
Return Value
The filtered value.
Examples
/**
* Example of how to use the 'uap_option_peepso_all_users' filter hook.
* This example demonstrates how to modify the options for the 'All Users' setting
* in the PeepSo integration, potentially by adding or removing specific user roles
* or filtering them based on custom criteria.
*
* @param array $option The original option array containing settings for the 'All Users' field.
* @return array The modified option array.
*/
function my_custom_uap_peepso_all_users_options( $option ) {
// Let's assume $option['options'] is an array where keys are user roles
// and values are their display names.
// For instance:
// $option['options'] = [
// 'administrator' => 'Administrator',
// 'editor' => 'Editor',
// 'author' => 'Author',
// 'subscriber' => 'Subscriber',
// ];
// Example: If we want to exclude the 'administrator' role from being selectable
if ( isset( $option['options']['administrator'] ) ) {
unset( $option['options']['administrator'] );
}
// Example: If we want to add a custom placeholder option or a special group
// Let's pretend we want to add an option for "Premium Users" if a certain condition is met.
// This is a hypothetical scenario for demonstration.
if ( current_user_can( 'manage_options' ) ) { // Only add if the current user is an admin
$option['options']['premium_users'] = __( 'Premium Users', 'your-text-domain' );
}
// It's important to return the modified $option array.
return $option;
}
add_filter( 'uap_option_peepso_all_users', 'my_custom_uap_peepso_all_users_options', 10, 1 );
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:199
public function get_users( $label = null, $option_code = 'PPUSERS', $args = array(), $bynames = false ) {
if ( ! $label ) {
$label = esc_attr__( 'PeepSo member', 'uncanny-automator' );
}
$args = wp_parse_args(
$args,
array(
'uo_include_any' => false,
'uo_any_label' => esc_attr__( 'Any PeepSo member', 'uncanny-automator' ),
)
);
$options = array();
if ( $args['uo_include_any'] ) {
$options['-1'] = $args['uo_any_label'];
}
global $wpdb;
$users = $wpdb->get_results( "SELECT * FROM `{$wpdb->prefix}peepso_users`", ARRAY_A );
if ( count( $users ) > 0 ) {
foreach ( $users as $user ) {
if ( false === $bynames ) {
$options[ $user['usr_id'] ] = get_user_by( 'id', $user['usr_id'] )->display_name;
} else {
$user_by_id = get_user_by( 'id', $user['usr_id'] );
if ( $user_by_id instanceof WP_User ) {
$options[ $user['usr_id'] ] = sprintf( '%s %s [%s]', $user_by_id->last_name, $user_by_id->first_name, $user_by_id->user_email );
} else {
$options[ $user['usr_id'] ] = '#' . $user['usr_id'];
}
}
}
}
$option = array(
'option_code' => $option_code,
'label' => $label,
'input_type' => 'select',
'required' => true,
'options' => $options,
'relevant_tokens' => array(),
);
return apply_filters( 'uap_option_peepso_all_users', $option );
}