Forum Replies Created
-
AuthorPosts
-
Vladimir
KeymasterIt seems I fixed the issue. Make another test and share the result.
The reason was at the filtering code from functions.php:
$ag = get_field('analytics_group_name','user_' . $current_user->ID); if ( !isset( $ag ) ) { return ''; }get_field() may return ”, and !isset() check was wrong in the such case. I replaced !isset() with empty():
if ( empty( $ag ) ) { return ''; }and ‘Pages’ started to open with the single page only.
Vladimir
KeymasterHi Erik,
I reproduced the described issue. I will try to find a reason.
Vladimir
KeymasterYes, it’s a way to resolve the redirection issue caused by admin menu restrictions.
01/04/2020 at 11:36 in reply to: Pro Version – Multisite – Add new user -> editor -> all sites #6738Vladimir
Keymaster1st, add new user as editor to the main site.
2nd, go to “Network Admin->Users”, find just added user, click ‘Capabilities’ link under that user row.
3rd, click “Update Network”. URE Pro will add the user with role granted to him to all sites of the multisite network.Documentation article on the subject:
31/03/2020 at 15:13 in reply to: Access to all Posts of a specific Custom Post Type and limit other Pages by ID #6735Vladimir
KeymasterThis version just adds additional condition:
if ( in_array( 'scholarships', $user->roles ) ) { // Role ID if ($post_type=='scholarship') { // CPT ID $restrict_it = false; } } else if ( in_array( 'sdol-page-editor', $user->roles ) && in_array( 'applications_tools', $user->roles )) { // user has both roles at the same time if ( $post_type==='app_tools' ) { $restrict_it = false; // Do not restrict editing for Applications & Tools } }31/03/2020 at 14:48 in reply to: Access to all Posts of a specific Custom Post Type and limit other Pages by ID #6734Vladimir
KeymasterUse ‘sdol-page-editor’ for the role ID and ‘app_tools’ for the post_type. If you return false for ‘app_tools’, URE will fully exclude this custom post type from edit restrictions.
Something like this:
if ( in_array( 'sdol-page-editor', $user->roles ) && in_array( 'applications_tools', $user->roles )) { // user has both roles at the same time if ( $post_type==='app_tools' ) { $restrict_it = false; // Do not restrict editing for Applications & Tools } }31/03/2020 at 13:39 in reply to: Access to all Posts of a specific Custom Post Type and limit other Pages by ID #6731Vladimir
Keymaster1st issue was resolved. User icomm sees ‘Pages’ menu now. Problem was that his 1st role has “Admin menu” “Not Selected” blocking model, but the 2nd role – “Selected”. When URE builds general admin menu for 2 roles it take blocking model from the 1st role and if blocking model of the 2nd role is different then it’s ignored. As a result ‘Pages’ menu was blocked via “Admin menu” restrictions set for the 1st role.
2nd part, it’s possible to allow user to see/edit the single page via its ID, but has edit access to the full list of another custom post type. Use custom filter ure_restrict_edit_post_type for this purpose.
Let me know if you will need help with a code for this custom filter.
31/03/2020 at 05:14 in reply to: Access to all Posts of a specific Custom Post Type and limit other Pages by ID #6728Vladimir
KeymasterDoes such user see ‘Pages’ menu item or just doesn’t see any pages at the pages list?
Anyway I don’t see a problem with user capabilities granted to the user via roles.
Try to deactivate all plugins. Will it change something? If Yes, activate plugins back one by one to isolate a problem.30/03/2020 at 15:10 in reply to: Access to all Posts of a specific Custom Post Type and limit other Pages by ID #6725Vladimir
KeymasterHi,
1st, deactivate temporally URE’s edit restrictions add-on at the URE Settings page and be sure that your user with both roles really has unrestricted access to the custom post type and pages.
2nd, turn ON URE’s edit restrictions add-on and try to tune restrictions for this user.
When you put page ID to the list of allowed for editing, URE automatically prohibits all other ID (even from other post types). It’s possible to change this for the selected custom post type via ure_restrict_edit_post_type custom filter.Let me know the result and we will continue with access to the single page, if it will be needed.
Vladimir
KeymasterDid you add ‘edit_theme_options’ capability to ‘author’ role?
Vladimir
KeymasterErik,
I updated custom code at functions.php to this version:
function fetch_analytics_posts(){ global $post; $current_user = wp_get_current_user(); $ag = get_field('analytics_group_name','user_' . $current_user->ID); if ( !isset($ag) ) { return ''; } $posts = get_posts(array( 'suppress_filters' => true, 'numberposts' => -1, 'post_type' => 'page', 'meta_query' => array( 'relation' => 'OR', array( 'key' => 'analytics_group_name', 'value' => $ag, 'compare' => 'IN', ), ), )); foreach($posts as $post){ $list .= $post->ID.','; } $list = rtrim($list, ','); wp_reset_postdata(); // echo 'allowed posts:'. $list; return $list; } add_filter('ure_edit_posts_access_id_list', 'ure_edit_posts_access_set_id_list_cu', 10, 1); function ure_edit_posts_access_set_id_list_cu($list) { remove_filter('ure_edit_posts_access_id_list', 'ure_edit_posts_access_set_id_list_cu', 10); $ag_posts_list = fetch_analytics_posts(); add_filter('ure_edit_posts_access_id_list', 'ure_edit_posts_access_set_id_list_cu', 10, 1); if ( empty( $ag_posts_list ) ) { return $list; } if ( empty( $list ) ) { return $ag_posts_list; } $list .= ', '. $ag_posts_list; return $list; }I tested with existing user with ‘Program Editor’ role. When I turn ON SBU002 analytics group for her, she sees 30 pages only. (Pay attention that some pages with empty analytics group field were returned by your get_posts() query).
Vladimir
KeymasterErik,
I moved get_posts() out of filter function and saved its result inside global variable. So filter function looks now as:
function ure_edit_posts_access_set_id_list_cu($list) { global $ag_posts_list; if ( empty( $ag_posts_list ) ) { return $list; } if ( empty( $list ) ) { return $ag_posts_list; } $list .= ', '. $ag_posts_list; return $list;I created successfully new page ‘Test 124’ under user with ‘Program Editor’.
Make your own test and let me know the result.24/03/2020 at 16:01 in reply to: User role rights are not refreshing when a user role is selected from drop down #6712Vladimir
KeymasterI suppose that your browser uses older version of ure.js file. Try to force browser page refresh after you open URE page. Will it start work as expected?
If page refresh will not help, open browser JavaScript console and look for JavaScript error messages. Show what do you see.Vladimir
KeymasterAnother suggestion –
You use get_posts() inside your filter function. URE’s uses ‘pre_get_posts’ hook to define the list of the allowed posts, thus calling get_posts() inside filter function may lead to the endless recursion and finally to the problem with available memory. So try to switch off this custom filter before to call get_posts(), then restore it back, like this:remove_filter('ure_edit_posts_access_id_list', 'ure_edit_posts_access_set_id_list_cu'); $posts = get_posts(array( 'numberposts' => -1, 'post_type' => 'page', 'meta_query' => array( 'relation' => 'OR', array( 'key' => 'analytics_group_name', 'value' => $ag, 'compare' => 'IN', ), ), )); add_filter('ure_edit_posts_access_id_list', 'ure_edit_posts_access_set_id_list_cu');If this will not help, let me know, we will try to switch off/restore directly URE’s global post edit access filter.
Vladimir
KeymasterYes, your function as filter should always return value. If there is nothing to change, then return unchanged value it got as input parameter.
500 is not a problem. There are installations with thousands posts and/or pages, which work fine.
Try to turn ON wordpress debug mode with writing to file. Add this lines to wp-config.php for that:
define('WP_DEBUG', true); define('WP_DEBUG_LOG', true);WordPress will write all error messages to wp-content/debug.log file in this case. Reproduce the error.
Look if ‘user-role-editor-pro’ is mentioned at the error messages.Another variant for investigation:
Strange, that out of memory error is raised at different times from different sources. Can you try to deactivate all plugins except URE and test again. In case error will go away, activate plugins back one by one until error will return. Just in case some other plugin eats to much memory. -
AuthorPosts