Skip to content

Instantly share code, notes, and snippets.

@digamber89
Last active October 1, 2020 09:32
Show Gist options
  • Save digamber89/b824b14fe593273e580a3c4edd2544f3 to your computer and use it in GitHub Desktop.
Save digamber89/b824b14fe593273e580a3c4edd2544f3 to your computer and use it in GitHub Desktop.
Author Meetings Only
function show_only_authors_own_meetings( $query ) {
global $pagenow;
if ( 'edit.php' != $pagenow || ! $query->is_admin ) {
return false;
}
if ( $query->is_main_query() && $query->get( 'post_type' ) == 'zoom-meetings' ) {
$user = wp_get_current_user();
$privileged_roles = [ 'administrator' ]
if ( ! empty( array_intersect( $user->roles, $privileged_roles ) ) ) {
return false;
}
add_filter( 'views_edit-zoom-meetings', [ $this, 'zoom_meeting_views' ], 11 );
$query->set( 'author', $user->ID );
}
}
add_action( 'pre_get_posts', 'show_only_authors_own_meetings' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment