Forwarding pages
-
I would prefer to not use a plugin but put code in my functions file to do this.
I am working on a custom site for a photographer who does one-on-one photography lessons and she wants to give students their own gallery pages but also have a page to show select photos (with permission) from some of her students.
She ways the student gallery to be at /gallery/student-gallery/ and the page with photos to be at /gallery/.
The second page will be for logged out users to get a feel for the pictures she and her students take!She would like for students who are always logged in to always be forwarded to their gallery when clicking gallery in the navigation. This is the code I came up with to accomplish this but it does not seem to be working…. where am I going wrong?
function my_redirect_user_by_role($user_login, $user) { global $user; echo $role_name = $user->roles[0]; // redirect for student if ( 'student' === $role_name && is_page('gallery') ) { wp_redirect('https://mysite.com/gallery/student-gallery/'); exit; } } add_action('wp_login','my_redirect_user_by_role');
Thank you in advance.
- The topic ‘Forwarding pages’ is closed to new replies.