lundi 2 février 2015

Show only the author's posts in ACF Relationship Custom Field


I created a Relationship Custom Field in Advanced Custom Fields, where the users can see and select a post from another custom post type (for eg. products) The problem is that I have a thousands of posts and for the users is a bad experience to search in a dozens of items until find their posts.


Is there any solution that users should be able to see only the items created by them?


Mention that I already put the following code in my function.php but not working for this custom field:


`function mypo_parse_query_useronly( $wp_query ) { if ( strpos( $_SERVER[ 'REQUEST_URI' ], '/wp-admin/edit.php' ) !== false ) { if ( !current_user_can( 'update_core' ) ) { global $current_user; $wp_query->set( 'author', $current_user->id ); } } }


add_filter('parse_query', 'mypo_parse_query_useronly' );`


enter image description here


Any help will be appreciated!


Many, many thanks in advance!


Regards, Burebista





Aucun commentaire:

Enregistrer un commentaire