0

I'm using "Passwordless Login with OTP / SMS & Email - Facebook Account Kit" for login.

I want to redirect user to http://www.domain.com/author/<username>/screen after they log in

this is the code I used

$current_user = wp_get_current_user();
if ( is_user_logged_in() ) {
    $redirect = ('http://www.domain.com/author/'.$current_user->user_login.'/screen'); }

It redirect to http://www.domain.com/author/screen without the username. can anyone help me with this

0
function login_redirect( $redirect_to, $request, $user ){
    $URL ="http://www.abcgg.com";
    return $URL;
}
add_filter( 'login_redirect', 'login_redirect', 10, 3 );
0

The problem is that wp_get_current_user() is not available until after pluggable is run. Try adding your code to a later hook:

add_action( 'wp_login', function () {
    $current_user = wp_get_current_user();
    if ( is_user_logged_in() ) {
        $redirect = ('http://www.domain.com/author/'.$current_user->user_login.'/screen'); 
    }
});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.