I need help re-writing a redirect function…
-
I recently inherited a membership enabled site?that requires the subscriber role to login before they can access the content on the pages under the Games menu item (Slots, Table Games, Scratch-off Games).
?
The site currently has a function (in functions.php file, in a child theme) that redirects you to the login page if you click on one of the three links mentioned above. After you login, you?are redirected back to the Slots page. There lies the problem. No matter which menu item you select, after logging in, you are redirected to the same page, Slots. I need to expand the function to do the following:1. if you click Slots, after logging in, you are redirected back to Slots.
2. if you click Table Games, after logging in, you are redirected back to Table Games – not Slots as it currently does.
3. if you click Scratch-off Games, after logging in, you are redirected back to Scratch-off Games – not Slots as it currently does.This is the my first time using the forum, so I’m not sure if this is even the correct place to ask this question. This coding task to accomplish 1-3 above is beyond what I’m able to do, so I’m looking for some help.
Here is the current function
/*
* Make Private Posts visible to Subscribers
* Typically only visible to admin or editor
*/function ws_private_posts_subscribers(){
?$subRole = get_role( ‘subscriber’ );
?$subRole->add_cap( ‘read_private_posts’ );
?$subRole->add_cap( ‘read_private_pages’ );
}
add_action( ‘init’, ‘ws_private_posts_subscribers’ );add_action(‘wp’,’redirect_stuffs’, 0);
function redirect_stuffs(){
global $wpdb;
$current_user = wp_get_current_user();
? ? if ($wpdb->last_result[0]->post_status == “private” && (! user_can( $current_user, “subscriber” ))):
? ? ? ? wp_redirect( wp_login_url(), 301 );
? ? ? ? exit();
? ? endif;
}? ? ?
The page I need help with: [log in to see the link]
- The topic ‘I need help re-writing a redirect function…’ is closed to new replies.