Filter uncanny-automator-pro

uap_option_get_profile_types

Filters the available profile types for user registration when using the BuddyBoss integration.

add_filter( 'uap_option_get_profile_types', $callback, 10, 1 );

Description

This filter allows developers to modify the profile types available for use within BuddyBoss or BuddyPress integrations in Uncanny Automator. It's applied when Uncanny Automator is retrieving profile types, enabling custom filtering or augmentation of the options list. Developers can add, remove, or alter profile type definitions before they are presented to the user.


Usage

add_filter( 'uap_option_get_profile_types', 'your_function_name', 10, 1 );

Return Value

The filtered value.


Examples

<?php
/**
 * Example of filtering the 'uap_option_get_profile_types' hook.
 *
 * This example demonstrates how to add a custom profile type to the list
 * of available profile types when Uncanny Automator is fetching them.
 * It's assumed this code would be placed within a WordPress plugin or theme's
 * functions.php file.
 */
add_filter( 'uap_option_get_profile_types', 'my_custom_profile_types', 10, 1 );

/**
 * Adds a custom profile type to the list of available profile types.
 *
 * @param array $option The original array of profile type options.
 * @return array The modified array of profile type options, including the custom one.
 */
function my_custom_profile_types( $option ) {
	// Assume $option is an array and we want to add to its 'options' key.
	// In a real scenario, you would likely fetch available profile types
	// from the BuddyBoss/BuddyPress API and then potentially add your own
	// or modify existing ones.

	// Let's simulate adding a new profile type.
	// In a real scenario, you'd get the actual ID and Name from BuddyBoss/BuddyPress.
	$custom_profile_type_id   = 'my_custom_buddyboss_type';
	$custom_profile_type_name = esc_html__( 'My Special Profile Type', 'my-text-domain' );

	// Ensure the 'options' key exists and is an array.
	if ( ! isset( $option['options'] ) || ! is_array( $option['options'] ) ) {
		$option['options'] = array();
	}

	// Add our custom profile type to the options.
	// The format typically is array( 'ID' => 'Label' )
	$option['options'][ $custom_profile_type_id ] = $custom_profile_type_name;

	// You might also want to adjust other parameters like 'label' or
	// 'custom_value_description' if your custom type requires specific handling.
	// For this example, we'll leave them as is, assuming the original filter
	// provided appropriate defaults.

	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

uncanny-automator-pro/src/integrations/buddyboss/helpers/buddyboss-pro-helpers.php:212
uncanny-automator-pro/src/integrations/buddypress/helpers/buddypress-pro-helpers.php:138

public function get_profile_types(
		$label = null,
		$option_code = 'BDBPROFILETYPE',
		$args = array()
	) {

		$args = wp_parse_args(
			$args,
			array(
				'uo_include_any' => false,
				'uo_any_label'   => esc_attr_x( 'Any profile type', 'Buddyboss', 'uncanny-automator' ),
			)
		);

		if ( ! $label ) {
			$label = esc_attr_x( 'Profile type', 'Buddyboss', 'uncanny-automator' );
		}

		$options = array();

		if ( Automator()->helpers->recipe->load_helpers ) {
			if ( $args['uo_include_any'] ) {
				$options[- 1] = $args['uo_any_label'];
			}
			if ( function_exists( 'bp_get_active_member_types' ) ) {
				$types = bp_get_active_member_types(
					array(
						'fields' => '*',
					)
				);

				if ( $types ) {
					foreach ( $types as $type ) {
						$options[ $type->ID ] = $type->post_title;
					}
				}
			}
		}
		$option = array(
			'option_code'              => $option_code,
			'label'                    => $label,
			'input_type'               => 'select',
			'required'                 => true,
			'options'                  => $options,
			'custom_value_description' => esc_html_x( 'Profile Type ID', 'BuddyBoss', 'uncanny-automator' ),
		);

		return apply_filters( 'uap_option_get_profile_types', $option );
	}

Scroll to Top