I'm trying to create a simple redirect when someone tries accessing a certain page depending on user role.
I've created a site with membership functionality that offers certain things to paid members. Free members can only access one page after login but if they know the URL to the paid area they can see the content. I was wondering if there's a way to create a 301 redirect so that when the free member tries to go on the paid page, it redirects them back to the free area.
Is this possible? If you need more info, please ask!
Thanks David
You can also try like this and make it more wordpress friendly.
function role_redirections() {
$loggedin_user = wp_get_current_user();
if (!is_user_logged_in() || !in_array( 'memorial_user', (array) $loggedin_user->roles )) {
$location1 = get_option( 'siteurl' ) .'/member-portal/';
header('Location: '.$location1.'');
}
}
add_action('wp_head', 'role_redirections');
Thank's very much! I'll use this instead.