Filter
uncanny-automator-pro
uap_option_get_all_private_groups
Filters user private groups data before it is retrieved, allowing modification of all retrieved private groups.
add_filter( 'uap_option_get_all_private_groups', $callback, 10, 1 );
Description
Allows modification of the options array used to retrieve all private groups from WP User Manager. Developers can filter this hook to alter how private groups are fetched, customize their display, or add/remove specific groups from the available options before they are used by Uncanny Automator Pro, particularly useful for dynamic or conditional group selections.
Usage
add_filter( 'uap_option_get_all_private_groups', 'your_function_name', 10, 1 );
Parameters
-
$option(mixed) - This parameter holds the current value of the option being filtered, which typically represents the data related to private groups from the WP User Manager integration.
Return Value
The filtered value.
Examples
// Filter to modify the options for private groups in WP User Manager Pro integration.
// This example adds a custom option to the array if a specific condition is met.
add_filter( 'uap_option_get_all_private_groups', function( $options ) {
// Check if the current user has a specific role that grants them access to a custom feature.
if ( current_user_can( 'manage_options' ) ) {
// If the condition is met, add a new key-value pair to the options array.
// This could represent a custom setting or a flag for the integration.
$options['custom_private_group_setting'] = true;
}
// Always return the modified (or unmodified) options array.
return $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
uncanny-automator-pro/src/integrations/wp-user-manager/helpers/wp-user-manager-pro-helpers.php:238
public function get_all_private_groups( $label = null, $option_code = 'WPUMPRIVATEGROUPS', $args = array() ) {
if ( ! $label ) {
$label = esc_attr__( 'Private group', 'uncanny-automator-pro' );
}
$token = key_exists( 'token', $args ) ? $args['token'] : false;
$is_ajax = key_exists( 'is_ajax', $args ) ? $args['is_ajax'] : false;
$is_any = key_exists( 'is_any', $args ) ? $args['is_any'] : false;
$target_field = key_exists( 'target_field', $args ) ? $args['target_field'] : '';
$end_point = key_exists( 'endpoint', $args ) ? $args['endpoint'] : '';
$args = array(
'post_type' => 'wpum_group',
'posts_per_page' => 999,
'orderby' => 'title',
'order' => 'ASC',
'post_status' => 'publish',
'meta_query' => array(
array(
'key' => '_group_privacy_method',
'value' => 'private',
'compare' => '=',
),
),
);
$options = Automator()->helpers->recipe->options->wp_query(
$args,
$is_any,
esc_attr__( 'Any private group', 'uncanny-automator-pro' )
);
$option = array(
'option_code' => $option_code,
'label' => $label,
'input_type' => 'select',
'required' => true,
'supports_tokens' => $token,
'is_ajax' => $is_ajax,
'fill_values_in' => $target_field,
'endpoint' => $end_point,
'options' => $options,
);
return apply_filters( 'uap_option_get_all_private_groups', $option );
}