Filter
uncanny-automator-pro
uap_option_list_mycred_points_types_for_ranks
Filters myCred points types available for UAP ranks before they are displayed.
add_filter( 'uap_option_list_mycred_points_types_for_ranks', $callback, 10, 1 );
Description
Filters the list of myCred point types available for Uncanny Automator Pro ranks. Developers can modify the provided array to customize which point types appear in the dropdown, enabling or disabling specific point types for rank integration. This hook fires when the list of selectable myCred point types is being generated.
Usage
add_filter( 'uap_option_list_mycred_points_types_for_ranks', 'your_function_name', 10, 1 );
Parameters
-
$option(mixed) - This parameter contains the default label for the point type selection field.
Return Value
The filtered value.
Examples
/**
* Filters the list of myCRED point types available for Uncanny Automator Pro ranks.
*
* This example demonstrates how to conditionally remove a specific myCRED point type
* from the dropdown list if it's not meant to be used for rank progression within
* Uncanny Automator.
*
* @param array $options An array of myCRED point types. Each element is typically an associative array
* with 'label' (the point type name) and 'value' (the point type ID).
* @return array The filtered array of myCRED point types.
*/
add_filter(
'uap_option_list_mycred_points_types_for_ranks',
function ( $options ) {
// Example: Remove the 'leaderboard_points' point type from the available options
// if you don't want it to be selectable for Uncanny Automator ranks.
$point_type_to_exclude = 'leaderboard_points';
// Iterate through the options and unset the one we want to exclude
foreach ( $options as $key => $option ) {
if ( isset( $option['value'] ) && $option['value'] === $point_type_to_exclude ) {
unset( $options[ $key ] );
break; // Stop once we've found and removed it
}
}
// Return the modified array of options
return $options;
},
10, // Priority: 10 is the default, meaning this filter runs after others.
1 // Accepted args: The filter passes only one argument: $options.
);
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/mycred/helpers/mycred-pro-helpers.php:76
public function list_mycred_points_types_for_ranks( $label = null, $option_code = 'MYCREDPOINTSTYPES', $args = array() ) {
if ( ! $label ) {
$label = __( 'Point type', 'uncanny-automator' );
}
$token = key_exists( 'token', $args ) ? $args['token'] : false;
$is_ajax = key_exists( 'is_ajax', $args ) ? $args['is_ajax'] : false;
$target_field = key_exists( 'target_field', $args ) ? $args['target_field'] : '';
$end_point = key_exists( 'endpoint', $args ) ? $args['endpoint'] : '';
$options = array();
$types = mycred_get_types();
if ( ! empty( $types ) ) {
foreach ( $types as $key => $type ) {
$settings = mycred( $key );
if ( isset( $settings->core['rank']['base'] ) && $settings->core['rank']['base'] == 'current' ) {
$options[ $key ] = $type;
}
}
}
$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,
'description' => 'Ranks must be set to “Use Current Balance” to be available in this dropdown',
);
return apply_filters( 'uap_option_list_mycred_points_types_for_ranks', $option );
}