Filter
uncanny-automator
uap_option_list_bo_rank_types
Filters the available badge types for ranking users, allowing customization of ranking options within BadgeOS.
add_filter( 'uap_option_list_bo_rank_types', $callback, 10, 1 );
Description
Fires when retrieving the rank types for BadgeOS integration. Developers can filter the `$option` array to modify or add to the list of rank types. This hook is useful for customizing which BadgeOS rank types are available in Uncanny Automator.
Usage
add_filter( 'uap_option_list_bo_rank_types', 'your_function_name', 10, 1 );
Return Value
The filtered value.
Examples
add_filter( 'uap_option_list_bo_rank_types', 'my_custom_badgeos_rank_types', 10, 1 );
/**
* Customizes the list of BadgeOS rank types available in Uncanny Automator.
*
* This function can be used to filter the rank types that are displayed
* in the Uncanny Automator integration with BadgeOS. For example, you might
* want to exclude certain rank types from being selectable.
*
* @param array $option The array of rank types being filtered.
* @return array The modified array of rank types.
*/
function my_custom_badgeos_rank_types( $option ) {
// Example: Remove a specific rank type if its slug is 'retired-rank'.
if ( isset( $option['options']['retired-rank'] ) ) {
unset( $option['options']['retired-rank'] );
}
// Example: Add a new rank type (if you had a custom one registered elsewhere).
// This is a hypothetical example, as new rank types are typically
// registered via BadgeOS hooks.
// $option['options']['my-custom-rank'] = array(
// 'text' => __( 'My Custom Rank', 'uncanny-automator' ),
// 'value' => 'my-custom-rank',
// );
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/badgeos/helpers/badgeos-helpers.php:223
public function list_bo_rank_types( $label = null, $option_code = 'BORANKTYPES', $args = array() ) {
if ( ! $label ) {
$label = esc_attr__( 'Rank 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();
global $wpdb;
if ( Automator()->helpers->recipe->load_helpers ) {
//$posts = Automator()->helpers->recipe->options->wp_query( [ 'post_type' => 'rank_types' ] );
$posts = $wpdb->get_results(
"SELECT ID, post_name, post_title, post_type
FROM $wpdb->posts
WHERE post_type LIKE 'rank_types' AND post_status = 'publish' ORDER BY post_title ASC"
);
if ( ! empty( $posts ) ) {
foreach ( $posts as $post ) {
$options[ $post->post_name ] = $post->post_title;
}
}
}
$type = 'select';
$option = array(
'option_code' => $option_code,
'label' => $label,
'input_type' => $type,
'required' => true,
'supports_tokens' => $token,
'is_ajax' => $is_ajax,
'fill_values_in' => $target_field,
'endpoint' => $end_point,
'options' => $options,
'custom_value_description' => _x( 'Rank type slug', 'BadgeOS', 'uncanny-automator' ),
);
return apply_filters( 'uap_option_list_bo_rank_types', $option );
}