wordpress show only media user has uploaded in wp_editor wordpress show only media user has uploaded in wp_editor wordpress wordpress

wordpress show only media user has uploaded in wp_editor


You might try this plugin: http://wordpress.org/extend/plugins/view-own-posts-media-only/

Alternatively try this:

add_action('pre_get_posts','ml_restrict_media_library');function ml_restrict_media_library( $wp_query_obj ) {    global $current_user, $pagenow;    if( !is_a( $current_user, 'WP_User') )    return;    if( 'admin-ajax.php' != $pagenow || $_REQUEST['action'] != 'query-attachments' )    return;    if( !current_user_can('manage_media_library') )    $wp_query_obj->set('author', $current_user->ID );    return;}

Source: http://wpsnipp.com/index.php/functions-php/restricting-users-to-view-only-media-library-items-they-upload/#comment-810649773


alternatively since WordPress 3.7

add_filter( 'ajax_query_attachments_args', "user_restrict_media_library" );function user_restrict_media_library(  $query ) {    global $current_user;    $query['author'] = $current_user->ID ;    return $query;}


I use API/Filter Reference/ajax query attachments args for WP 4.3.1 and works

add_filter( 'ajax_query_attachments_args', 'show_current_user_attachments', 10, 1 );function show_current_user_attachments( $query = array() ) {    $user_id = get_current_user_id();    if( $user_id ) {        $query['author'] = $user_id;    }    return $query;}

just add on functions.php

or check this link WP Codex