Last active
January 30, 2018 07:25
-
-
Save jerrickhakim/a7887c32ace97a7cf30c845c8b16ac03 to your computer and use it in GitHub Desktop.
WordPress Redirect Based On User Role & Page ID. This code is great for Restrict Content Pro. I use it to redirect the sign up pages to the members area. That is if they have purchased the specific level and each level is assigned a custom user role with the same access as a subscriber. However, this code can be used for a variety of application…
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
/* CUSTOM REDIRECT PER USER ROLE AND PAGE ID */ | |
add_action('template_redirect', 'redirect_user_role'); | |
function redirect_user_role($priority = 1) | |
{ | |
if(current_user_can('Administrator') && is_page('1988')) | |
{ | |
wp_redirect('/urlhere'); | |
} | |
if ( is_user_logged_in() && is_page('1883')) | |
{ | |
wp_redirect('/account'); | |
} | |
} | |
/* END CUSTOM REDIRECT PER USER ROLE AND PAGE ID */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment