Subscriber role
-
-
Maurizio CodaParticipant# 1 year, 2 months ago
Hello,
I have installed WP Customer Area and WP Customer Area – Additional Owner Types and it works fine with users of a specific role created with User Role Editor plugin.
However, I would like users with the role “subscriber” not to go to the private area but to a specific page of mine.
Subscribers must have no relation to the private area.
Can you help me?
Thank you -
ThomasKeymaster# 1 year, 2 months ago
Hello,
I guess I would recommend using a simple snippet to do that, like this:
/** * Prevent subscriber to access the dashboard */ function wpca_redirect_subscribers() { // Make sure WPCA is activated if(!function_exists('cuar_is_customer_area_page')) return; // If current page is a WPCA page or post and user is subscriber, redirect to a custom page if ((cuar_is_customer_area_page(get_queried_object()) || cuar_is_customer_area_private_content(get_the_ID())) && current_user_can('subscriber')) { wp_safe_redirect('https://mysite.com/welcome'); exit; } } add_action('init', 'wpca_redirect_subscribers');
I actually did not test, in order to answer you quicker, but do not hesitate to try that with differrent custom roles and see if it works as expected. Simply change the URL to whatever you need and it should work. Check our code snippets documentation to learn how to use it.
Regards.
Want to help WP Customer Area? It only takes few seconds!
Rate & review the plugin on WordPress.org 🙂 -
Maurizio CodaParticipant# 1 year, 2 months ago
cieo and thanks for the snippet,
something is still not working, after logging in the subscriber is always sent to the private area and not to the mil custom link.
There is something telling the user to go to the private area.
Can you help me?
thanks Maurizio -
-
ThomasKeymaster# 1 year, 2 months ago
Hi,
after logging in the subscriber is always sent to the private area and not to the mil custom link
I understand why, but if the subscriber then refresh the page (once he’s viewing the dashboard), does it this time work as expected? He’s he being redirect to the custom page?
Regards.
Want to help WP Customer Area? It only takes few seconds!
Rate & review the plugin on WordPress.org 🙂 -
Maurizio CodaParticipant# 1 year, 2 months ago
Hi Thomas,
no, it’s not redirecting using above snippet
-
Maurizio CodaParticipant# 1 year, 2 months ago
CIao THomas,
to be clearer I need “Subscriver” users to be disregarded by the WP Customer Area for which I have created a dedicated user type with “User Role Editor”.
The subscriber should not enter the private area at allThank you
Maurizio
-
ThomasKeymaster# 1 year, 2 months ago
Hello,
I understand your request. We could probably add a new global permission to prevent some user role to be able to access any WPCA feature.
But for now, I can only propose you to redirect your users to another page. This one works:
/** * Prevent subscriber to access the dashboard */ function wpca_redirect_subscribers() { // Make sure WPCA is activated if(!function_exists('cuar_is_customer_area_page')) return; // Make sure we're browsing the private area if (!cuar_is_customer_area_page(get_queried_object()) && !cuar_is_customer_area_private_content(get_the_ID())) return; // If current page is a WPCA page or post and user is subscriber, redirect to a custom page if (current_user_can('subscriber')) { wp_safe_redirect('https://mysite.com/welcome'); exit(); } } add_action('template_redirect', 'wpca_redirect_subscribers');
Change wp_safe_redirect to wp_redirect if you are redirecting to an external site other than yours.
Regards.
Want to help WP Customer Area? It only takes few seconds!
Rate & review the plugin on WordPress.org 🙂 -
-
ThomasKeymaster# 1 year, 2 months ago
Hello,
This page does not redirect correctly
What do you mean? Do you get any error from the browser ? What is the URL displayed in the URL bar of your browser after a subscriber tried to browse the private area?
Are you sure about the URL and the actual permissions given to a subscriber?
You are actually trying to redirect a subscriber to the admin area, which looks like a bit unexpected to me. I doubt he should be able to do that and should get, by default, an error like “You do not have sufficient permissions”. You could also get a kind of redirection loop error from your browser since WP Customer Area is by default configured to send back a subscriber to the private area.
If you’re getting such an error and if you’re really trying to redirect your subscriber to that page located in the admin area :
- You’ll need to make sure that the subscriber role is allowed to access the admin area. WP Customer Area will, by default, prevent the subscriber role to access it. You can give the subscriber role the permission to do that in Settings > WP Customer Area > Capabilites > General > Back-office > Access the WordPress admin area
It doesn’t mean your theme or any other plugin won’t prevent that, you’ll need to make sure about that. - You’ll also need to make sure that the subscriber role is allowed to access this “Bookly Calendar” page. Maybe check that in the documentation of that plugin or ask its author how you can change the behavior.
In order to make sure that the snippet correctly works, Maybe first try to redirect him to a page from the frontend of your site (not a wp-admin page).
Also, before reactivating that redirection to the admin area, make sure that he is allowed to access the bookly page from your admin area.
Best regards.
Want to help WP Customer Area? It only takes few seconds!
Rate & review the plugin on WordPress.org 🙂 - You’ll need to make sure that the subscriber role is allowed to access the admin area. WP Customer Area will, by default, prevent the subscriber role to access it. You can give the subscriber role the permission to do that in Settings > WP Customer Area > Capabilites > General > Back-office > Access the WordPress admin area
-
The topic ‘Subscriber role’ is closed to new replies.