Contents
How to prevent access to certain user roles?
Roles vs. Capabilities: As role names can change and as roles are just groups of capabilities, it’s best to check against a capability, not a role name. You can find a list of built in roles and capabilities here. Just look at what the most restrictive access is and search for a matching capability. Then assign it above.
How to disable the WordPress dashboard for subscribers?
We’re essentially going to add a new action to the admin init in order to achieve our objective of disabling the WordPress dashboard for subscribers. Add this to your functions.php file: The above code will redirect subscribers to the home page. You could redirect to any page on your site here.
Why do I need to disable admin Ajax in WordPress?
This is to ensure that admin-ajax.php still works for logged out users, otherwise it tries to redirect. That’s pretty much it. Very straight forward. You could also target specific capabilities instead of for user roles, a full list can be found on the WordPress codex.
Can a subscription give you access to the dashboard?
People who buy a subscription product being given dashboard access is completely crazy and our customers have seriously freaked out when they log in and see the dashboard because they have no idea what is goign on or how to get back to the home page, so this is superb!
How to limit access to your WordPress dashboard?
The Subscriber role is very limited and only allows the user to read content on the frontend of the site and manage their profiles. This can all be done in the admin area of WordPress. To do this, simply go to Settings and then General. From there, just set any New User Default Role as a Subscriber.
Why do I not have access to the admin page?
You do not have sufficient permissions to access this admin page. Reason: The current user doesn’t have the “read” capability that is required to access the “Dashboard” menu item. Thanks for contributing an answer to WordPress Development Stack Exchange!
How to prevent access to wp-admin for?
It is placed in functions.php file. The condition used is, if the user can’t manage_options or edit_posts. Just revisited that answer as it wasn’t updated in a long time.