Filter uncanny-toolkit-pro

uo_group_signup_notification_type

Filters the type of notification sent when a group signup occurs.

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

Description

Filters the notification type sent after a user signs up for a group. Developers can modify this to send custom email notifications to the admin or user. The hook fires after a new user is created during group signup. An empty string is the default value.


Usage

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

Parameters

$new_user_id (mixed)
This parameter, which is an empty string by default, is used to filter or modify the notification type sent when a user signs up for a group.

Return Value

The filtered value.


Examples

<?php
/**
 * Change the default user notification type for group signups.
 *
 * By default, wp_new_user_notification() sends a generic notification.
 * This filter allows you to customize the notification type, for example,
 * to send a specific "Welcome to the group" email instead.
 *
 * @param string  $notification_type The current notification type string.
 * @param int     $new_user_id       The ID of the newly registered user.
 * @return string The modified notification type string.
 */
add_filter( 'uo_group_signup_notification_type', function ( $notification_type, $new_user_id ) {
	// Check if the user has been successfully created.
	if ( ! empty( $new_user_id ) ) {
		// You could add more complex logic here, for example:
		// - Check user role.
		// - Check which group they signed up for (if that data is available in scope).
		// - Check specific settings.

		// For this example, let's assume we want to send a specific notification
		// for users who are registered as 'member' roles.
		$user_info = get_userdata( $new_user_id );
		if ( $user_info && in_array( 'member', (array) $user_info->roles ) ) {
			// This assumes you have a custom notification type registered or a specific
			// email sending function that handles 'group_member_welcome'.
			return 'group_member_welcome';
		}

		// Otherwise, return the default or the modified type from a previous filter.
		return $notification_type;
	}

	// If user ID is not provided, return the default.
	return $notification_type;
}, 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:702

'last_name'       => $user_last,
						'user_registered' => date( 'Y-m-d H:i:s' ),
						'role'            => get_option( 'uo_groups_default_user_role', get_option( 'default_role', 'subscriber' ) ),
					)
				);
				if ( $new_user_id ) {
					// send an email to the admin alerting them of the registration
					$notification_type = apply_filters( 'uo_group_signup_notification_type', '', $new_user_id );
					wp_new_user_notification( $new_user_id, null, $notification_type );

					// log the new user in
					$frontEndLogin = uncanny_learndash_toolkitConfig::get_settings_value( 'uo_frontendloginplus_needs_verifcation', 'FrontendLoginPlus' );
					if ( empty( $frontEndLogin ) || 'on' !== $frontEndLogin ) {
						wp_set_auth_cookie( $new_user_id );
						wp_set_current_user( $new_user_id, $user_login );


Scroll to Top