Change WordPress user roles and capabilities › Forums › How to or FAQ › Defining Posts View Access in php
- This topic has 19 replies, 2 voices, and was last updated 3 years, 11 months ago by Vladimir.
-
AuthorPosts
-
11/01/2021 at 12:55 #7256VladimirKeymaster
Btw., if you use any caching plugin, try to use different computers for testing view access.
11/01/2021 at 14:08 #7257zunkParticipanthumm thanks for this support.
So the problem comes from my side…I can’t check the same setting as yours, because I’ve deleted ‘subscriber’, ‘contributor’, ‘author’, ‘editor’ roles.
I only create new roles with URE from none (“make copy of none”).
At the moment, I do not use any capability for my roles.
Any chance my prob could come from a capability missing (a one available in default “author” role)?
🙁11/01/2021 at 14:23 #7258VladimirKeymasterReally, when you create new role as a copy of ‘none’, URE adds to it at least one capability – ‘read’. Does your role has it? I did not make tests with absolutely empty roles.
It should not have difference what role do you use built-in or custom one. Role should exist and current user should have it.
I used ‘author’ role as an example only, it does not play a key role, what role to use.
11/01/2021 at 14:41 #7259zunkParticipantadd_filter( ‘ure_content_view_access_data_for_role’, ‘my_content_view_access_data_for_role’, 10, 2 );
function my_content_view_access_data_for_role( $restriction, $role_id ) {
if ( $role_id==’soc2′ ) {
$restriction[‘access_model’] = 2;
$restriction[‘access_error_action’] = 1;
$restriction[‘data’][‘posts’] = array(49, 101, 100, 99);
}
return $restriction;
}I’ve delete the rest of my php for a try, then desactivate all my plugins.
I’ve put the same setting in the post 99:
– View Access: Prohibit view;
– For Users: All visitors (logged in or not);
– Action: Return HTTP 404 error.
The 49, 101, and 100 use this settings:
View access: “Allow View”
For user: Any User Role
Action : Return HTTP 404 Errorit works for 49, 101, 100 but the 99 is still prohibited.
I really don’t understand my instal is pretty new.
I’ve create another user and a new role with “Read” capability, but this is the same. I do not have cache plugin, and I can see any change I do in live.Last hope could be a setting into URE settings that I miss or that I should uncheck?
I’ve also tried with “post_type Page” and it is the same than with a Custom Post Type..11/01/2021 at 14:57 #7260VladimirKeymasterLook if 99 post has category, which also has view restriction at category level. It’s just assumption about possible conflict with a hook. It should not take place though.
It it will not help. I can look at your data on site tomorrow. If it’s applicable send URL and admin login credentials to support [at-sign] role-editor.com
-
AuthorPosts
- You must be logged in to reply to this topic.