Forum Replies Created

Viewing 15 posts - 586 through 600 (of 2,506 total)
  • Author
    Posts
  • Vladimir
    Keymaster

    Hi,

    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
    Keymaster

    Did you add ‘edit_theme_options’ capability to ‘author’ role?

    Vladimir
    Keymaster

    Erik,

    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
    Keymaster

    Erik,

    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.

    Vladimir
    Keymaster

    I 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
    Keymaster

    Another 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
    Keymaster

    Yes, 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.

    Vladimir
    Keymaster

    1st of all, filter function should always return value.
    Replace

    
    if (!isset($ag)) {
       return; 
    } else {
    

    with

    
    if (!isset($ag)) {
       return $list; 
    } else {
    

    Is it too much posts (approximate quantity) has analytics group name, for which you get out of memory error?

    Vladimir
    Keymaster

    Hi Andrija,

    In this case this is may be interesting for you too:
    1) Base options saved by User Role Editor Pro:

    
    SELECT * FROM wp_options WHERE option_name LIKE 'user_role_editor';
    

    2) Data saved by URE add-ons:

    
    SELECT * FROM wp_options WHERE option_name LIKE 'ure_%';
    

    Before importing ure_posts_edit_access_data record to the live database take into account if posts/pages ID are the same at the source and targets databases.

    Vladimir
    Keymaster

    If you familiar with SQL and the tools like phpMyAdmin, it’s possible to export/import all user roles with less efforts. Suppose the database prefix is ‘wp_’.
    1) Find the WordPress db record with user roles:

    
    SELECT * FROM wp_options WHERE option_name='wp_user_roles';
    

    2) Update all user roles at once:

    
    UPDATE wp_options SET option_value='changed value here' WHERE option_id=NN LIMIT 1;
    

    This post explains in details how and where WordPress stores user roles data.

    Do you use any URE Pro additional modules at the test site?

    Vladimir
    Keymaster

    Can I check the example at your site/stage/dev copy? If that’s applicable, send URL, admin credentials and example details (CPT, category, role) to support [at-sign] role-editor.com

    Vladimir
    Keymaster

    Does post have a single category and/or user – single role? We have to take into account settings made for another categories and/or roles.

    Vladimir
    Keymaster

    In order to exclude restricted post from the search results you have to select the action “Show HTTP 404 error”. This option excludes restricted post from all listings.
    If ‘Show access error message’ is selected, post is shown at the search results, only its content is replaced with access error message.

    Vladimir
    Keymaster

    Hi Andrija,

    If you have not too much user roles you can use ‘Export/Import’ buttons to make this role by role. ‘Export’ button write currently selected role to the local file. ‘Import’ button imports role data from the selected file (previously exported).

    This will resolve your task if you don’t care about data set for/by URE additional modules.

    in reply to: Hide Menu item from specific user role #6685
    Vladimir
    Keymaster

    Thanks for the good suggestion for further development. It’s impossible with current user interface though.
    I added custom filter ure_show_front_end_menu_item as a quick workaround. You may check any condition inside custom code hooked to it and hide menu item via it. Mentioned filter was added to beta version 4.51.b2. It’s available from the download page.

Viewing 15 posts - 586 through 600 (of 2,506 total)