1

I'm trying to come up with a wordpress page template (acting as a landing page) that redirects a user to another page based on their role.
ex. user with role editor goes to landing page and is redirected to "/editors-page/" user with role subscriber goes to landing page and is redirected to "/subscribers-page/"

I've come across so many plugins and custom functions that talk about redirecting at login but I'm using multisite and there are some complications using any of those examples so I've landed on the above solution.

Any help would be wonderful! Thanks so much!

1 Answer 1

0

You can use current_user_can() to check the user roles. https://developer.wordpress.org/reference/functions/current_user_can/

To check if the user is editor or administrator:

<?php if( current_user_can('editor') || current_user_can('administrator') ) { ?> // Stuff here for administrators or editors <?php } ?> 

Then to redirect you can use this:

header('Location: '.$newURL); 
2
  • This worked, sir!. Thank you. Commented Oct 2, 2019 at 16:27
  • If this worked, please mark the answer with the checkmark or rate it up. Commented Oct 2, 2019 at 16:42

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.