Action uncanny-learndash-toolkit

uo_login_after_register

Fires after a user account is successfully registered within the core system.

add_action( 'uo_login_after_register', $callback, 10, 1 );

Description

Fires after the register link is displayed on the login form. Developers can use this hook to add custom content or actions directly after the registration link on the frontend login page.


Usage

add_action( 'uo_login_after_register', 'your_function_name', 10, 1 );

Examples

<?php
/**
 * Example of using the 'uo_login_after_register' action hook.
 *
 * This function will send a welcome email to a user after they have successfully registered.
 * It assumes that the plugin providing this hook also provides user registration functionality.
 */
function my_custom_welcome_email_after_register( $user_id ) {
    // Ensure we have a valid user ID.
    if ( ! $user_id || ! is_numeric( $user_id ) ) {
        return;
    }

    $user = get_userdata( $user_id );

    if ( ! $user ) {
        return;
    }

    $user_email = $user->user_email;
    $user_login = $user->user_login;

    // Set up the email subject and content.
    $subject = sprintf( __( 'Welcome to %s, %s!', 'your-text-domain' ), get_bloginfo( 'name' ), $user_login );

    // You can customize the email content further.
    $message = sprintf(
        __( "Hi %s,nnWelcome to our website! We're excited to have you on board.nnBest regards,nThe %s Team", 'your-text-domain' ),
        $user_login,
        get_bloginfo( 'name' )
    );

    // Send the welcome email.
    $sent = wp_mail( $user_email, $subject, $message );

    // You might want to log success or failure for debugging.
    if ( $sent ) {
        // Optional: Add a log entry or meta data for the user.
        error_log( "Welcome email sent successfully to user ID: {$user_id}" );
    } else {
        error_log( "Failed to send welcome email to user ID: {$user_id}" );
    }
}
add_action( 'uo_login_after_register', 'my_custom_welcome_email_after_register', 10, 1 ); // The hook passes the user ID as the first argument.

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/templates/frontend-login/layout_1-login.php:224
src/templates/frontend-login/modern_ui-login.php:231

<?php do_action( 'uo_login_before_register' ); ?>

				<div class="ult-form-footer__signup">
					<a href="<?php echo $login->urls->register; ?>"><?php echo $login->strings->register; ?></a>
				</div>

				<?php do_action( 'uo_login_after_register' ); ?>

			<?php } ?>

		</div>

		<?php do_action( 'uo_login_after_footer' ); ?>


Scroll to Top