Support

Account

Forum Replies Created

  • You are the man!

    Now all works as it should.

    Thank you very much for that awesome support!

  • Thank you very much!

    i´ve tested your input and now the custom fields work as they should:) the only thing is that the user now see all uploaded files in the media library and not only his own…

  • Hi John,
    thank you very much for your efforts, here is the hole part, hope you can help 🙂

    /* CUSTOM CITYGUIDE FUNCTIONS */
    function isCityguideUser($wp_roles = array()){
    	$result = false;
    	if(count($wp_roles) == 0){
    		$wp_user = wp_get_current_user();
    		$wp_roles = $wp_user->roles;
    	}
    	foreach ($wp_roles as $index => $role) {
    		if(strpos($role, 'cityguide_') !== false){
    			$result = true;
    		}
    	}
    	return $result;
    }
    
    /*****************************************************************************/
    /****** PLEASE KEEP HERE ONLY CODE WHICH IS COMON FOR ALL GUIDE THEMES *******/
    /******** CUSTOM pre_get_posts FILTERS ARE IN ait-custom-functions.php ********/
    /*****************************************************************************/
    function altered_search($query) {
    	if($query->is_admin) {
    		// hotfix - wordpress consider all ajax calls as is_admin call
    		// on fronend logged users could see only their items/events
    		// TODO: replace by filter where I can register all custom ajax actions/handlers
    		if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'get-items:getHeaderMapMarkers') {
    			return $query;
    		}
    
    		if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'get-items:retrieve') {
    			return $query;
    		}
    
    		/* Display posts in admin for current user only */
    		$wp_user = wp_get_current_user();
    		if(isCityguideUser($wp_user->roles)){
    			$query->set('author', $wp_user->data->ID);
    		}
    		
    	} else {
    		if($query->is_main_query()){
    			if (isset($_GET['s']) && empty($_GET['s'])){
    				$query->is_search = true;
    			
    			}
    
    			// is woocommerce search
    			if(isset($query->query_vars['post_type']) && $query->query_vars['post_type'] == 'product'){
    			
    				return $query;
    			}
    			
    		
    			$query = apply_filters( 'ait_alter_search_query', $query );
    			
    			
    		}
    	}
    	return $query;
    }
    add_filter('pre_get_posts', 'altered_search');
  • Hi, run in the same problem with an AIT Theme (Eventguide),

    First im new to wordpress but i found out that there is a problem with a filter.

    My custom usergroups can not see the customfields the problem is in this:

    function altered_search($query) ...
    
    		/* Display posts in admin for current user only */
    		$wp_user = wp_get_current_user();
    		if(isCityguideUser($wp_user->roles)){
    		$query->set('author', $wp_user->data->ID);
    		} 
    
    add_filter('pre_get_posts', 'altered_search');

    When i comment the add_filter out the custom fields display but the user can also edit other post types.

    Does anyone have a solution or a hint for this?

    PS: The support from ait answer:

    Hello, seems like the filter which is needed to filter posts and show only posts created by currently logged in user may cause the problem, it’s part:
    if(isCityguideUser($wp_user->roles)){

    $query->set(‘author’, $wp_user->data->ID);

    }
    Unfortunately it’s important part for theme core functionality and users registered via our theme. I am sorry but we are not capable to customize theme scripts per customers needs to make working all third party plugins. Seems like this filter needs some workaround in order to work with other parts like custom fields from plugin.

    Thanks for understanding, Ivan.

Viewing 4 posts - 1 through 4 (of 4 total)