Forum Replies Created
-
AuthorPosts
-
Vladimir
KeymasterThis article is still up to date. Look at it as documentation page. Yes, it was written some months ago, but it describes a working feature, may be except of some minor changes.
Can this user edit posts or pages? “Posts/Pages/Custom Post Types Editor Restrictions” section is shown is a user profile page only for users who can edit posts or pages. Settings from this section does not bring to a user any new permissions. All it is about to restrict the existing editing access, narrow down it.
You will not see this section at user profile, if a user has ‘administrator’ role. There is no sense to restrict site super administrator.
Vladimir
KeymasterI followed this article always.
And selected “Subdirectories — a path-based network in which on-demand sites use paths” to not struggle configuring Apache with subdomains.Vladimir
KeymasterLook how it works at my test site – demo video.
Slightly enhanced code version. Update your copy:
add_filter('ure_edit_posts_access_id_list', 'ure_edit_posts_access_set_id_list'); function ure_edit_posts_access_set_id_list($list) { if (!current_user_can('edit_others_pages')) { return $list; } $slugs = array('shop', 'busket'); // input blocked pages slug here $id_list = array(); foreach($slugs as $slug) { $page = get_page_by_path($slug); if (!empty($page)) { $id_list[] = $page->ID; } } if (count($id_list)>0) { $id_list_str = implode(',', $id_list); $list .= $id_list_str; } return $list; } add_filter('ure_edit_posts_access_restriction_type', 'ure_edit_posts_access_set_restriction_type'); function ure_edit_posts_access_set_restriction_type($restriction_type) { if (current_user_can('edit_others_pages')) { $restriction_type = 2; // Block } return $restriction_type; }Vladimir
KeymasterHi Chris,
Yes, you have to create a 2nd account: open purchase page without login to the site and use another user name and email address.
Vladimir
KeymasterThis code does not depend from a page ID. It blocks edit access for pages with ‘shop’ and ‘busket’ slugs for any user with ‘edit_others_pages’ capability for any subsite.
add_filter('ure_edit_posts_access_id_list', 'ure_edit_posts_access_set_id_list'); function ure_edit_posts_access_set_id_list($list) { $current_user = wp_get_current_user(); $lib = URE_Lib_Pro::get_instance(); if (!current_user_can('edit_others_pages')) { return $list; } $slugs = array('shop', 'busket'); $id_list = array(); foreach($slugs as $slug) { $page = get_page_by_path($slug); if (!empty($page)) { $id_list[] = $page->ID; } } $id_list_str = implode(',', $id_list); $list .= $id_list_str; return $list; } add_filter('ure_edit_posts_access_restriction_type', 'ure_edit_posts_access_set_restriction_type'); function ure_edit_posts_access_set_restriction_type($restriction_type) { $current_user = wp_get_current_user(); $lib = URE_Lib_Pro::get_instance(); if (current_user_can('edit_others_pages')) { $restriction_type = 2; // Block } return $restriction_type; }If you will wish to add some edit restriction for user with ‘edit_others_pages’ manually, you should take into account that this restricton should be the same type “Block” in order to not break this code and vice versa.
Vladimir
KeymasterGive me more details. Does it one page for a subsite?
Show a list of pages with ID and permalinks (without domain) and describe conditions, how will you decide what permalink for what site to select.Vladimir
KeymasterIt possible to extend a logic of the ‘set_id_list’ function using WP function url_to_postid(), in order to return a page ID related to current site.
Vladimir
KeymasterTry to deactivate and activate back User Role Editor Pro.
Vladimir
KeymasterI got it. Thanks. It’s really comes from “WC Subscriptions” plugin. But I have another picture at my test. Menu items is protected by ‘edit_posts’ capability and it’s available for blocking at ‘Admin menu’:

Vladimir
KeymasterThis screenshot belongs to other add-on: Content view restrictions, which works for front-end.
I recommended to use another one. If you provide that those restricted pages will have the same IDs at any subsite of your network, you can setup the list of restricted pages, like “1, 3, 7” via custom filters ‘ure_edit_posts_access_id_list’ and ‘ure_edit_posts_access_restriction_type’ as a must use plugin – which will work for any subsite.
add_filter('ure_edit_posts_access_id_list', 'ure_edit_posts_access_set_id_list'); function ure_edit_posts_access_set_id_list($list) { $current_user = wp_get_current_user(); $lib = URE_Lib_Pro::get_instance(); if ($lib->user_can_role($current_user, 'editor')) { $list .= ',1,3,7'; } return $list; } add_filter('ure_edit_posts_access_restriction_type', 'ure_edit_posts_access_set_restriction_type'); function ure_edit_posts_access_set_restriction_type($restriction_type) { $current_user = wp_get_current_user(); $lib = URE_Lib_Pro::get_instance(); if ($lib->user_can_role($current_user, 'editor')) { $restriction_type = 2; // Block } return $restriction_type; }Vladimir
KeymasterOK. Can you share “WC Subscriptions” plugin copy with me (support [at-sign] role-editor.com) via Dropbox, Google Drive or similar?
I will investigate this in my local test environment then.Vladimir
KeymasterHi,
You can achieve this with Edit access restrictions add-on. You can prohibit with it the editing of a list of pages by ID for the editor role.
Vladimir
KeymasterHi,
Did you looked at “Admin menu” under “Administrator” role? You have to look “Admin menu” under role which has required capability to see needed menu item.
I don’t have this menu item with active WooCommerce. I suppose it was added by some other plugin or by WC add-on.
Vladimir
KeymasterIt seems a subject for enhancement. You can see ‘create_shop_coupons’ capability under “Custom post types->Coupons”, but you don’t see it under “Custom capabilities->Woocommerce->Coupons”, right? I will update a list of capabilities related to WooCommerce.
Vladimir
KeymasterHi,
Problem is not related to the content access. It caused by JavaScript error from jQuery. It takes place for the demo user and does not for admin.
Content is shown usually by jQuery effect during page scrolling. But page for demo user has JavaScript errors, which prevents this effect execution, as I suppose. So a problem is related to a theme.I changed a role for demo user to subscriber temporally. Content (product description) was visible.
So there is an issue with a page for user with ‘administrator’ role but the username other than ‘admin’, which cause a JavaScript error.
This JavaScript error takes place even with User Role Editor Pro deactivated.
-
AuthorPosts