Created
March 8, 2014 00:09
-
-
Save jfcode/9422915 to your computer and use it in GitHub Desktop.
This file contains 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
/** | |
* Allow access to own content only | |
*/ | |
function my_authored_content($query) { | |
//get current user info to see if they are allowed to access ANY posts and pages | |
$current_user = wp_get_current_user(); | |
// set current user to $is_user | |
$is_user = $current_user->user_login; | |
//if is admin or 'is_user' does not equal #username | |
if (!current_user_can('manage_options')){ | |
//if in the admin panel | |
if($query->is_admin) { | |
global $user_ID; | |
$query->set('author', $user_ID); | |
} | |
return $query; | |
} | |
return $query; | |
} | |
add_filter('pre_get_posts', 'my_authored_content'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment