Forum Replies Created
-
AuthorPosts
-
Vladimir
KeymasterAnother question – if you repeat the test will it show the same result – all pages 1st, then the list according to restrictions?
Vladimir
KeymasterDo you use any caching plugin? If Yes, switch off caching for the restricted role.
15/01/2021 at 03:15 in reply to: Ability to limit categories available to content authors in certain roles. #7273Vladimir
KeymasterHi Trevor,
It’s possible to allow/prohibit editing/creation of the post with selected categories for user or/and role using “Posts, pages edit restrictions” add-on.
Vladimir
KeymasterClarify also what do you mean under “user can ONLY view certain page IDs”. I suppose – view allowed pages at the list of pages available for editing at the wp-admin, right?
Vladimir
KeymasterHi,
Can not repeat this at the latest test. Check if user has another role(s) granted, which has edit restrictions also and may change the result which you wish.
Vladimir
KeymasterHi,
Thanks for the provided information. WPACU plugin uses ‘administrator’ role by default as the permission when defines its admin menu and checks current user permissions.
But it allows to replace ‘administrator’ with custom permission via filter. For example, code below provides access to WPACU plugin for any user with ‘manage_options’ capability:add_filter('wpacu_access_role', 'replace_wpacu_admin_permission', 10, 1 ); function replace_wpacu_admin_permission( $cap ) { $cap = 'manage_options'; return $cap; }
You can add it to the functions.php file of your active theme.
Vladimir
KeymasterIs ‘Site Manager’ role created by some plugin? I suppose the situation when that plugin recreates this role every time its loaded.
What if you add ‘manage_options’ to any other role? Will it stay there?
If Yes, use workaround – assign role with ‘manage_options’ to the user with ‘Site Manager’ role as the 2nd one.Vladimir
KeymasterHi,
Share plugin .zip with support [at-sign] role-editor.com via DropBox, Google Drive or similar service. I will look what permissions it requires. I install such software locally and use in the investigation purpose only.
Vladimir
KeymasterLook 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
Vladimir
KeymasterReally, 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.
Vladimir
KeymasterBtw., if you use any caching plugin, try to use different computers for testing view access.
Vladimir
KeymasterOK. I made own test.
Set for the post ID=3267 at the post editor these values:
– View Access: Prohibit view;
– For Users: All visitors (logged in or not);
– Action: Return HTTP 404 error.As a result the post is not accessible for not logged-in and logged-in users.
Then I added the code:add_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=='author' ) { $restriction['access_model'] = 2; $restriction['access_error_action'] = 1; $restriction['data']['posts'] = array( 3267 ); // posts/pages ID list } return $restriction; }
The post is not accessible for not logged-in and logged-in users with any role except administrator and author.
Vladimir
KeymasterHi,
I need first to allow “All user login” to view these Posts
Why do you need this? Did you try to prohibit view for all user login for those posts at the post level and overwrite the condition via hook for select role(s) only? I mean restriction define at the hook will be final and overwrite one which define earlier at the post editor.
Vladimir
KeymasterHi,
Yes, it’s possible. Just select suitable access model:
$restriction[‘access_model’] = 1; // Prohibit view
and
$restriction[‘access_model’] = 2; // Allow view$restriction[‘data’][‘posts’] = array( 10, 20, 30 ); // posts/pages/custom post types ID list
Post ID array works for any post type: as WordPress built-in posts and page, as any custom post type.
Vladimir
KeymasterWhile code version above work for the user with ‘user-manager’ role only, this version works for all users including one with ‘administrator’ role:
add_filter('ure_show_additional_capabilities_section', 'ure_show_additional_capabilities_section'); function ure_show_additional_capabilities_section( $show ) { /* Remove comment if do not wish to apply this for administrators also $lib = URE_Lib::get_instance(); if ($lib->is_super_admin()) { return $show; } */ return false; }
-
AuthorPosts