Forum Replies Created
-
AuthorPosts
-
Vladimir
KeymasterThanks for the feedback.
Just in case it will be helpful, as a ‘must use’ plugin it should work without any “include” in functions.php and thus, for any theme, just from wp-content/mu-plugins folder:
https://codex.wordpress.org/Must_Use_PluginsVladimir
KeymasterI offer you to remove related code from the functions.php file. Take file from this zip
https://storage.googleapis.com/role-editor/downloads/block-pages-for-role.zip
replace ‘editor’ with ‘franchise’, input your own pages ID list and place this .php file to
wp-content/mu-plugins folder. Test that it works.
Then apply your own enhancements if needed.Vladimir
KeymasterCode you showed is incomplete and invalid. It lost the begin of restrict_posts_list() function. Please re-check, what you added to the functions.php
Vladimir
KeymasterThis is the updated version, which takes into account front-end and blocks editing selected pages. You need update it for your role.
add_action('pre_get_posts', 'restrict_posts_list'); function restrict_posts_list($query) { if ( !is_blog_admin()) { return $query; } if (current_user_can('administrator') || !current_user_can('editor')) { return $query; } $suppressing_filters = $query->get('suppress_filters'); // Filter suppression on? if ($suppressing_filters) { return query; } if ($query->query['post_type']=='page') { $posts_restriction_type = 2; // Prohibit $posts_list = array(709, 763); // comma separated list of pages IDs if ($posts_restriction_type==1) { // Allow $query->set('post__in', $posts_list); } else { // Prohibit $query->set('post__not_in', $posts_list); } } return $query; } // end of restrict_posts_list() function current_user_has_role($role_to_check) { global $current_user; $has_role = false; foreach($current_user->roles as $role) { if ($role===$role_to_check) { $has_role = true; break; } } return $has_role; } // end of current_user_has_role() function get_pages_capabilities() { $cap_object = new stdClass(); $cap_object->capability_type = 'page'; $cap_object->capabilities = array(); $cap_object->map_meta_cap = true; $capabilities = (array) get_post_type_capabilities($cap_object); return $capabilities; } add_filter('map_meta_cap', 'block_edit_pages', 10, 4); function block_edit_pages($caps, $cap = '', $user_id = 0, $args = array()) { if (current_user_has_role('administrator') || !current_user_has_role('editor')) { return $caps; } if (substr($cap, 0, 4)=='read') { // do not block read capabilities return $caps; } $posts_restriction_type = 2; // Prohibit $posts_list = array(709, 763); // comma separated list of pages IDs $capabilities = get_pages_capabilities(); if (!isset($capabilities[$cap])) { return $caps; } if (count($args) > 0) { $post_id = $args[0]; } else { $post_id = filter_input(INPUT_GET, 'post', FILTER_SANITIZE_NUMBER_INT); } if (empty($post_id)) { return $caps; } $post = get_post($post_id); if (empty($post) || $post->post_type!=='page') { return $caps; } $do_not_allow = in_array($post_id, $posts_list); // not edit these pages if ($posts_restriction_type == 1) { $do_not_allow = !$do_not_allow; // not edit other pages } if ($do_not_allow) { $caps[] = 'do_not_allow'; } return $caps; } // end of block_edit_pages()
Vladimir
KeymasterHi Robert,
Thanks for the information.
Refund was done.Regards,
Vladimir.Vladimir
KeymasterAdd to the begin of function:
function restrict_post_list($query) { if (is_super_admin() || current_user_can('administrator')) { return $query; } ...
or change the initial
if
condition to:if (is_blog_admin() && !(is_super_admin() || current_user_can('administrator')) && current_user_can('franchise')) {
Vladimir
KeymasterAntKat,
This is a version of code modified to work with a list of pages slugs:add_action('pre_get_posts', 'restrict_posts_list'); function restrict_posts_list($query) { if ( !(is_blog_admin() && current_user_can('editor')) ) { return $query; } $suppressing_filters = $query->get('suppress_filters'); // Filter suppression on? if ($suppressing_filters) { return query; } if ($query->query['post_type']=='page') { $posts_restriction_type = 2; // Prohibit $posts_slugs = array( 'jobs', 'post-to-our-blog', 'sample-page' ); $posts_list = array(); // comma separated list of pages IDs foreach($posts_slugs as $post_slug) { $page = get_page_by_path($post_slug); if ($page) { $posts_list[] = $page->ID; } } if (empty($posts_list)) { return $query; } if ($posts_restriction_type==1) { // Allow $query->set('post__in', $posts_list); } else { // Prohibit $query->set('post__not_in', $posts_list); } } return $query; } // restrict_posts_list()
Vladimir
KeymasterList of custom user capabilities used at the FSQM menu:
Menu Item Capability
FSQM Pro view_feedback
Dashboard view_feedback
View all Forms manage_feedback
New Form manage_feedback
Import/Export Forms manage_feedback
Form Category manage_feedback
Report & Analysis view_feedback
View a Submission view_feedback
View all Submissions manage_feedback
Settings manage_feedbackVladimir
KeymasterHi Tash,
If it’s a paid product please send its copy to [email protected]
I will use it at my localhost for the investigation purpose only.
If it’s a plugin from WordPress repository send here its download link.Vladimir
KeymasterHi Helen,
Pro version includes its own copy of a free version (or the core of a User Role Editor). So you can remove free version. The only thing that you should remember is that both versions (free and Pro) use the same place to store their settings data. So if you delete free version via WordPress Plugins Delete link, plugin will delete automatically its settings data. You will have to configure User Role Editor Pro Settings again after that.
Right decision in your case is to delete free version folder (user-role-editor) via FTP not via WordPress.Vladimir
KeymasterHi,
Thanks for letting me know. I will add it.
Vladimir
KeymasterHi Robert,
Do not use “Block Not Selected” option if you should allow access to the “Posts” menu.
‘edit.php’ URL (which is needed to edit selected post) is obviously not selected at admin menu (as this link is not included to the menu) and thus it is blocked.
I did not get to the conclusion (universal decision) how to resolve similar issues for this moment.Please try the development version 4.19.b7, which you can get after login from the same download page. It addresses some “Admin menu access” add-on issues related to those you described.
Permanently I live in Russia (GMT+6). But currently and until the next weekend I’m in Czech Republic (GMT+2) and have access to the computer by the evenings only.
Regards,
Vladimir.Vladimir
KeymasterFixed: I added role “Centre Management” to the “Wishlist Member”->Settings->Configuration->Miscellaneous->”WishList Member Page/Post Options Access”.
Vladimir
KeymasterHi,
Thanks. I made successful test with custom role for the built-in post.
Does this custom role see “Wishlist Member” content protection options for the built-in posts and does not see them for the custom post type only?Vladimir
KeymasterHi,
The known problem with custom roles is missed user levels:
https://www.role-editor.com/wordpress-user-levels-deprecated-just-partially/If your custom role does not include “deprecated” user levels try to turn on the same levels set as an “Author” role contains. May be it will help you to resolve a problem.
In other case I need “Wishlist Member” plugin copy to test it and find a reason of described problem. You may send it to [email protected]
-
AuthorPosts