Support

Account

Home Forums General Issues Allow roles to be set to certain users Reply To: Allow roles to be set to certain users

  • Hi @planktonwebdesign

    Thanks for the extra info. Knowing this, I would not create a custom location rules. What you should do is create your field group with a field for each user. You need to have some sort of patern in the field name which has either the user’s ID or the user’s username in it. So perhaps “accept_job_dave” or “accept_job_3”.

    Then, use the filter acf/load_field (http://www.advancedcustomfields.com/resources/filters/acfload_field/) to remove fields.

    Lets say the current logged in user is “jeff”. In your filter, you would target all fields, or perhaps only all radio fields (explained in docs).

    Then, your code would look at the field name ($field[‘name’]). If this name included the string “accept_job_”, then you would compare the currentl logged in user to the field like so:

    
    <?php 
    
    if( strpos($field['name'], 'accept_job_') !== false )
    {
    	// accept_job_ was found in field name
    	$user = str_replace('accept_job_', '', $field['name']);
    	
    	
    	// $user is no 'jeff', find curent logged in user
    	$current_user_name = wp_function_to_find_current_username();
    	
    	
    	// compare and completely remove field if this user is not meant to see it!
    	if( $current_user_name != $user )
    	{
    		$field = null;
    	}
    	
    	
    	return $field;
    }
    
     ?>
    

    I hope that code example helps explain what you need to do.

    Thanks
    E