Created
February 21, 2024 22:09
-
-
Save yuriinalivaiko/4b44cfd038f46fef9bbf97e79aabc50d to your computer and use it in GitHub Desktop.
Redirect users to a different URL the first time they log in.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Redirect users to a different URL the first time they log in. | |
add_action( 'um_on_login_before_redirect', 'my_on_login_before_redirect', 9, 1 ); | |
function my_on_login_before_redirect( $user_id ) { | |
$first_login = get_user_meta( $user_id, '_um_first_login', true ); | |
if ( empty( $first_login ) ) { | |
update_user_meta( $user_id, '_um_first_login', current_time( 'mysql', true ) ); | |
// Set a custom redirect URL for the first time login here. | |
$redirect_url = '/user/?um_action=edit'; | |
um_safe_redirect( $redirect_url ); | |
exit; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment