Skip to content

Instantly share code, notes, and snippets.

@yuriinalivaiko
Created February 21, 2024 22:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yuriinalivaiko/4b44cfd038f46fef9bbf97e79aabc50d to your computer and use it in GitHub Desktop.
Save yuriinalivaiko/4b44cfd038f46fef9bbf97e79aabc50d to your computer and use it in GitHub Desktop.
Redirect users to a different URL the first time they log in.
<?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