WordPress.org

Ready to get started?Download WordPress

Forums

User role without access to the backend (5 posts)

  1. Teo Maragakis
    Member
    Posted 3 years ago #

    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?

  2. Teo Maragakis
    Member
    Posted 3 years ago #

    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
  3. 12changeme
    Member
    Posted 3 years ago #

    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?

  4. Teo Maragakis
    Member
    Posted 3 years ago #

    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!

  5. Teo Maragakis
    Member
    Posted 3 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic