Filter
uncanny-automator-pro
uap_option_peepso_all_user_roles
Filters the list of all available user roles for PeepSo integration within the Ultimate Affiliate Pro plugin.
add_filter( 'uap_option_peepso_all_user_roles', $callback, 10, 1 );
Description
Fires when retrieving all PeepSo user roles for an Uncanny Automator action or trigger. Developers can filter the `$option` array to modify the roles available for selection. This hook is executed during the initialization of Automator's PeepSo integration options.
Usage
add_filter( 'uap_option_peepso_all_user_roles', 'your_function_name', 10, 1 );
Parameters
-
$option(mixed) - This parameter contains the current value of the option being filtered.
Return Value
The filtered value.
Examples
// Add a custom role to the list of available roles for a PeepSo integration in Uncanny Automator.
add_filter(
'uap_option_peepso_all_user_roles',
function( $option ) {
// Assuming $option is an array representing the current user roles available.
// For example, it might look like:
// $option = array(
// 'administrator' => 'Administrator',
// 'editor' => 'Editor',
// );
// Let's say we want to add a custom role called 'PeepSo Moderator'.
$custom_role_slug = 'peepso_moderator';
$custom_role_name = __( 'PeepSo Moderator', 'your-text-domain' );
// Add the custom role to the $option array.
// We check if it already exists to avoid duplicates, though in most scenarios
// this filter is applied before custom roles are added by other plugins,
// so it's less likely to be a duplicate.
if ( ! isset( $option[ $custom_role_slug ] ) ) {
$option[ $custom_role_slug ] = $custom_role_name;
}
// Return the modified array of roles.
return $option;
},
10, // Priority: Default priority.
1 // Accepted Args: The filter hook passes only one argument ($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
uncanny-automator-pro/src/integrations/peepso/helpers/peepso-pro-helpers.php:67
public function get_roles( $label = null, $option_code = 'PPUSERSROLE', $args = array() ) {
if ( ! $label ) {
$label = esc_attr__( 'Roles', 'uncanny-automator' );
}
$args = wp_parse_args(
$args,
array(
'uo_include_any' => false,
'uo_any_label' => esc_attr__( 'Any role', 'uncanny-automator' ),
)
);
$options = array();
if ( $args['uo_include_any'] ) {
$options[- 1] = $args['uo_any_label'];
}
$options = $options + $this->filtered_roles();
$option = array(
'option_code' => $option_code,
'label' => $label,
'input_type' => 'select',
'required' => true,
'options' => $options,
'relevant_tokens' => array(
$option_code => esc_attr__( 'Role', 'uncanny-automator' ),
),
);
return apply_filters( 'uap_option_peepso_all_user_roles', $option );
}