Support

Account

Forum Replies Created

  • Need moar info! Does it work properly in a different browser? What browser(s) are you using, and do any of them show errors in the debug / dev tools consoles? (tip: F12 to open tools, usually)

    Next step in troubleshooting might be to change your theme to one of the defaults (Twentyeleven, twentytwelve, etc) and see if the fields work properly then. If they’re still broken, disable all plugins (except for ACF of course) and test it again! Hopefully somewhere in there you can narrow down the source of the problem.

  • Aha, well in that case you were totally on the right path!

    Filtering by “author” takes a user ID, while filtering by “author_name” will take a text string. Try this:

    add_action( 'pre_get_posts', 'filtre');
    function filtre($query) {
    
    	if( !is_admin() ) {
    		$query->set('author', get_current_user_id() );
     	}
    	return $query;
    }

    Or alternatively, you could get the string name first and filter by “author_name” instead:

        $user = wp_get_current_user();
        $query->set('author_name', $user->data->user_nicename );
    
  • Sample PHP export for an image field named “test”:

    array (
    	'key' => 'field_51db3a97ed096',
    	'label' => 'test',
    	'name' => 'test',
    	'type' => 'image',
    	'save_format' => 'object',
    	'preview_size' => 'thumbnail',
    	'library' => 'all',
    ),

    I would be curious to hear about whether adding this array into your code produces an image field properly.

  • So the linked post talks about limiting the results of post relationship custom field objects. This loop can be accessed and modified via AJAX hook path like so:

    function my_post_object_query( $args, $field, $post )
    {
        // modify the order
        $user_id = get_current_user_id();
            $args['author'] = $user_id;
        $args['post_type']="business";
    
        // uncomment and test to see all set arguments:
        // echo '<pre>'.print_r($args, true).'</pre>';
    
        return $args;
    }
     
    // filter for every field
    add_filter('acf/fields/post_object/query', 'my_post_object_query', 10, 3);

    Since post relationship field results can be updated dynamically, this should let you restrict the results for every updated display. This particular example limits the results in two ways: by post type “business” and also by current user!

    This is a pretty handy little snippet, I’m hanging on to this guy.

  • Check it out – just throw “old.” in front of the url to get to the old forums!

    http://old.support.advancedcustomfields.com/discussion/6459/restrict-post-object-selection-only-to-the-author

    Not sure about your actual question though… will get back to you on that one.

Viewing 5 posts - 76 through 80 (of 80 total)