I'm using "Passwordless Login with OTP / SMS & Email - Facebook Account Kit" for login.
I want to redirect user to /<username>/screen
after they log in
this is the code I used
$current_user = wp_get_current_user();
if ( is_user_logged_in() ) {
$redirect = ('/'.$current_user->user_login.'/screen'); }
It redirect to without the username. can anyone help me with this
I'm using "Passwordless Login with OTP / SMS & Email - Facebook Account Kit" for login.
I want to redirect user to http://www.domain/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/author/'.$current_user->user_login.'/screen'); }
It redirect to http://www.domain/author/screen
without the username. can anyone help me with this
2 Answers
Reset to default 0function login_redirect( $redirect_to, $request, $user ){
$URL ="http://www.abcgg";
return $URL;
}
add_filter( 'login_redirect', 'login_redirect', 10, 3 );
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/author/'.$current_user->user_login.'/screen');
}
});
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745302392a4621514.html
评论列表(0条)