• I am using the CaPa Protect plugin to create a customer area for my website. Works well but there is a detail. All the default roles of the WP system can access (even minimally) the backend. I want to create a “Customer” user role which will be able to login (with the normal login screen) and use the frontend capabilities according to the plugin setup, but under no circumstance should he be able to view the backend. Maybe redirect to the home page instead of the backend and even if there is no back-end link to the theme and he adds /wp-admin to the URL, he should be redirected to the home page. Any thoughts?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter Teo Maragakis

    (@teomaragakis)

    I am solving it slowly. I’ll write what I am doing for reference. First of I added the User Role Editor plugin and added the role “Customer” with same rights as the Subscriber role. Also changed the default role for new users to “Customer”. Now I have to find and add the following PHP commands somewhere (?):

    • Get logged user role
    • if role is customer redirect to website root

    I am using the Capa protect but most of my users will never make use of the backend. After login they will use the frontend capabilities according to the plugin setup. For the most advanced user there should be a link to go to /wp-admin. How can I redirect to the home page instead of wp-admin?

    Thread Starter Teo Maragakis

    (@teomaragakis)

    First you need to use function that checks what the user cannot do. For example, if you want all users to redirect apart from admins, try:

    if(!current_user_can( 'manage_options' )) {
    wp_redirect(get_option('siteurl'));
    }

    Try this and let me know if it worked!

    Thread Starter Teo Maragakis

    (@teomaragakis)

    Now a small update on how my customer area project is going:

    The CaPa Protect plugin used to recognize the custom roles created with the User Role Editor plugin, I updated at some point (unfortunately without noting the version) and now it does not, it only sees the default hardcoded roles.

    I’ll have to contact the developer.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘User role without access to the backend’ is closed to new replies.