Skip to content

Instantly share code, notes, and snippets.

@jfeliweb
Created October 16, 2014 17:28
Show Gist options
  • Save jfeliweb/003a13f5b7da6a01432f to your computer and use it in GitHub Desktop.
Save jfeliweb/003a13f5b7da6a01432f to your computer and use it in GitHub Desktop.
Restrict Authors to Edit Only Their Own Posts and Media
/* Only See Own Attachments */
add_action('pre_get_posts','users_attachments');
function users_attachments( $wp_query_obj ) {
global $current_user, $pagenow;
if( !is_a( $current_user, 'WP_User') )
return;
if( 'upload.php' != $pagenow )
return;
if( !current_user_can('delete_pages') )
$wp_query_obj->set('author', $current_user->id );
return;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment