I am trying to redirect my wordpress users to a certain page when they acces the front page. "Henk" has a page named "henkpage" and "John" has a page named "johnpage".
If the current user is Henk and he's on the front page, then i want that user to be redirected to mydomain.com/henkpage. And same with John: If current user is John and on the frontpage, then redirect to /johnpage. Could anyone help me?
I found this code that might have some usefull lines in them.
add_action( 'template_redirect', 'redirect_to_specific_page' );
function redirect_to_specific_page() {
if ( is_front_page() && is_user_logged_in() ) {
$current_user = wp_get_current_user();
$url = wpum_get_profile_url( $current_user );
wp_redirect( $url );
exit;
}
}
The code you posted should work for your purposes, but you'll need to modify this line
$url = wpum_get_profile_url( $current_user );
and set $url
to $current_user->display_name.'page'
or whatever you'd like it to redirect to.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.