Last active
          April 29, 2016 22:40 
        
      - 
      
 - 
        
Save jdhobbsuk/c7893286f6c37d3af1f5 to your computer and use it in GitHub Desktop.  
    ACF: Filter Post Object by posts owned by current author
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | function filter_acf_selection_by_ownership( $args, $field, $post ) { | |
| $user = get_current_user_id(); | |
| if(get_current_user_role() != 'administrator' || get_current_user_role() != 'editor'): | |
| $args['author'] = $user; | |
| endif; | |
| return $args; | |
| } | |
| // Post Object | |
| add_filter('acf/fields/post_object/query', 'filter_acf_selection_by_ownership', 10, 3); | |
| // Relationship | |
| add_filter('acf/fields/relationship/query', 'filter_acf_selection_by_ownership', 10, 3); | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment