Created
July 7, 2020 11:25
-
-
Save digamber89/16e3e0459139aaee89be7c7fb9c4cf7d to your computer and use it in GitHub Desktop.
Show Only Own Meetings for Users
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
<?php | |
add_action( 'pre_get_posts', 'show_only_authors_own_meetings' ); | |
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(); | |
add_filter( 'views_edit-zoom-meetings', 'zoom_meeting_views', 11 ); | |
$query->set( 'author', $user->ID ); | |
} | |
} | |
function zoom_meeting_views( $views ) { | |
foreach ( $views as $k => $v ) { | |
$new_views[ $k ] = preg_replace( '/\(\d+\)/', '', $v ); | |
} | |
$views = $new_views; | |
// remove trash status | |
unset( $views['mine'] ); | |
return $views; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment