Last active
February 16, 2023 17:08
-
-
Save samk-dev/fa530456b33e0b0e0784e45eb4daaf85 to your computer and use it in GitHub Desktop.
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 | |
// disallow users from accessing other users posts | |
function posts_for_current_author($query) { | |
global $pagenow; | |
if( 'edit.php' != $pagenow || !$query->is_admin ) | |
return $query; | |
if( !current_user_can( 'manage_options' ) ) { | |
global $user_ID; | |
$query->set('author', $user_ID ); | |
} | |
return $query; | |
} | |
add_filter('pre_get_posts', 'posts_for_current_author'); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment