I want all my users (contributors and authors too) but the admin to be redirected to the homepage if they try to view mysite.com/wp-admin/.
Contributors and Authors must be able to add and edit posts as usual, along with others they’ve to be forced to be redirected…
I’ve already removed the link to the dashboard…
I’ve also tried some plugins but the one that gets closer (Remove Dashboard Access) redirects to main page but prevents the contributors and authors from adding, editing and deleting posts.
Thanks!
Leave a Reply
You must be logged in to post a comment.
I been using this code for a while I think it was originaly on a plugin called wp block admin but this works. You just have tho change the required compatibility so that it does what you need, look at this
One addition: ALWAYS check to see if there is a logged in user otherwise you will prevent secured items from displaying on login screen:
Thank you so much for offering this solution 🙂
Unfortunately none of the above codes worked for me as they just redirected non admin to homepage even if I wanted authors and contributors to be able to add/edit and delete their posts…
I’ve ended removing the boxes in the dashboard and I solved (partially) my issue.
I added this in functions.php
I know this is still a old question but you can have a look.
This checking is very IMPORTANT “!defined( ‘DOING_AJAX’ )” when you use admin ajax call in frontend.
There’re only two things you need to check:
As long as we’re using the
template_redirect
hook we don’t have to check the login/register/password pages as the redirect will happen invisible to the user.Here’s the idea wrapped up as a little (mu-)plugin.