Change WordPress user roles and capabilities › Forums › Bug Reports › “no role for this site” & [user_role_editor roles=”none”]
- This topic has 9 replies, 2 voices, and was last updated 2 years, 11 months ago by TWarrior.
-
AuthorPosts
-
31/10/2021 at 17:42 #7746TWarriorParticipant
Hello,
I have users with no role (“no role for this site”)
The shortcode:
[user_role_editor roles=”none”]You dont have a role[/user_role_editor]
doesnt work for those users without role.Yes, I know that roles=”none” is only for not logged users, but the expected behaviour would be to include also users with “no role for this site”.
Thanks
01/11/2021 at 04:42 #7748VladimirKeymasterHi,
I confirm that currently role=”none” works for the not logged-in users only – traditionally, from very begin.
From one side, registered user without role can easily get access to the content with roles=”none”, it’s enough just logout. But, many sites use this shortcode to show content for not logged-in users only, to invite to login, for example. It will be not correct to show such content for logged-in users, which does not have role at the site. Backward compatibility is very important.What if to add something like ‘none_for_logged_in’, which will work especially for logged-in users, which does not have role for this site? Finally, it will be possible to user shortcode with parameters like roles=”none none_for_logged_in” especially for your case.
01/11/2021 at 08:48 #7749TWarriorParticipantthank you very much for your kind and quick response. It is a pleasure to be attended by the responsible of this great plugin.
Forgive me, but I don’t quite understand your answer.
I take this opportunity to explain my need (and I suppose that of many others who use “no role for this site”).
Traditionally, we used to show content only for active members (with any role such as administrator, editor, subscriber…) of the NGO with this code:
[user_role_editor roles=”none”]Please join our NGO, or loggin (text for non logged-in or not members yet)[/user_role_editor]
[user_role_editor except_roles=”none”]Some text only for NGO active members with any rol[/user_role_editor]But now we have members who have temporarily unsubscribed. We don’t want to delete their user accounts, so we thought that assigning them to “No role for this site” might be a solution.
So we would like these people without a role, even if they are logged in, not to be able to see content that is only for members with a role.
I understand the importance of backwards compatibility, but it is very strange that “role=none” actually means “role=logged_out”, and also there is no “role=no_role” to handle non-role users…
Let me humbly make you a proposal:
Add the value “role=no_role” to handle users with “no role on this site”.I think this way we could use the following code to display restricted content only for members with an assigned role:
[user_role_editor roles=”none,no_role”]Please join our NGO, or loggin (text for non logged-in or logged with “no role for this site”).[/user_role_editor]
[user_role_editor except_roles=”none,no_role”]Some text only for NGO active members with any rol[/user_role_editor]What is your opinion? Could it work?
21/11/2021 at 15:02 #7763TWarriorParticipanthello.
Just to make sure this is not forgotten. any news on this issue? any further clarification or explanation needed?
Thanks24/11/2021 at 03:27 #7765VladimirKeymasterHi,
Excuse for so huge delay with response. Yes, it will work. ‘no_role’ seems more nice for me. I will provide access to the beta for testing until the end of November, 2021.
24/11/2021 at 22:13 #7766TWarriorParticipantThank you
25/11/2021 at 04:04 #7768VladimirKeymasterTry development version 4.61.b1. It’s available from the “Download” page after login.
25/11/2021 at 16:44 #7771TWarriorParticipantThanks.
Tested with this code:TEST 1. roles=”none” for a user NOT LOGGED-IN:
RESULT: [user_role_editor roles=”none”]you are NOT LOGGED-IN[/user_role_editor]
[user_role_editor except_roles=”none”]you are LOGGED-IN[/user_role_editor]TEST 2. roles=”no_role” for a user with NO-ROLE-FOR-SITE (or not logged-in):
RESULT: [user_role_editor roles=”no_role”]your profile is NO-ROLE-FOR-SITE (or you are not logged-in)[/user_role_editor]
[user_role_editor except_roles=”no_role”]your profile is any, except NO-ROLE-FOR-SITE[/user_role_editor]WORKS PERFECT!
if you want to update
I have wrote this:
If you wish to show some content for users with no role (“— No role for this site —”) or not logged in, use this shortcode [user_role_editor roles=”no_role”].26/11/2021 at 04:29 #7772VladimirKeymasterThanks for the help.
28/11/2021 at 17:12 #7776TWarriorParticipantThanks to you for this multi propouse pluging.
-
AuthorPosts
- You must be logged in to reply to this topic.