Documentation > Developers > Filter Examples > Only Show Collections to Their Authors

Only Show Collections to Their Authors

1. Activate “author support” for picu collections

Have a look at the picu_cpt_collection_args filter on how to do it.

2. Adjust the capability with which picu can be used

By default picu can be used by an admin. Look at the picu_capability filter, on how to adjust the capability to your needs.

3. Only show collections to their authors

function my_picu_author_only( $wp_query ) {
	global $current_user;
	if ( is_admin() && ! current_user_can( 'manage_options' ) ) {
		if ( isset( $wp_query->query['post_type'] ) && $wp_query->query['post_type'] == 'picu_collection' ) {
			$wp_query->set( 'author', $current_user->ID );
		}
	}
}

add_action( 'pre_get_posts', 'my_picu_author_only' );Code language: PHP (php)

This should get you going. Please note, that this is a rough outline on how to get this done. You might still experience some quirks, eg. the author might see the wrong number of posts in the status filter above the collection list. (But I am sure you can figure that out by searching the web for a bit.)

Need help?

If you couldn’t find what you were looking for and need more assistance, please get in touch with us directly and we’re happy to help.