Filter uncanny-toolkit-pro

uo_group_signup_errors

Filters group signup errors before they are displayed to the user.

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

Description

Filters the array of errors encountered during group signup. Developers can use this hook to add custom error messages or modify existing ones before the group signup process continues. The `$errors` parameter contains the current error messages, and the second parameter is the object used to manage these errors.


Usage

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

Parameters

$errors (mixed)
This parameter contains any existing error messages that have been added to the group signup process.

Return Value

The filtered value.


Examples

/**
 * Example of adding a custom error message to group signup if a specific condition is met.
 *
 * This function hooks into the 'uo_group_signup_errors' filter to check if the
 * provided errors array contains a specific key and adds a custom message if it does.
 *
 * @param array $errors An array of error messages.
 * @param object $error_handler The error handler object.
 * @return array The modified array of error messages.
 */
add_filter( 'uo_group_signup_errors', function( $errors, $error_handler ) {
    // Check if a specific error, like 'group_join_error', is already present.
    if ( isset( $errors['group_join_error'] ) ) {
        // You could potentially modify the existing error message or add another.
        // For this example, we'll add a supplementary message.
        $errors['custom_group_message'] = esc_html__( 'Please review the group capacity before attempting to join.', 'your-text-domain' );
    }

    // You can also add entirely new errors based on other conditions if needed.
    // For example, if you had a custom check before this filter was applied:
    // if ( ! current_user_can( 'manage_options' ) ) {
    //     $errors['permission_denied'] = esc_html__( 'You do not have the necessary permissions to join this group.', 'your-text-domain' );
    // }

    return $errors;
}, 10, 2 );

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/classes/learn-dash-group-sign-up.php:684

if ( 0 === $remaining_seats ) {
						self::uncanny_group_signup_errors()->add( 'group_join_error', esc_html__( 'Sorry, the group you are trying to join is full.', 'uncanny-pro-toolkit' ) );
					}
				}
			}

			$errors = self::uncanny_group_signup_errors()->get_error_messages();
			$errors = apply_filters( 'uo_group_signup_errors', $errors, self::uncanny_group_signup_errors() );

			// only create the user in if there are no errors
			if ( empty( $errors ) ) {

				$new_user_id = wp_insert_user(
					array(
						'user_login'      => $user_login,


Scroll to Top