且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

wordpress 仅显示用户已在 wp_editor 中上传的媒体

更新时间:2023-11-30 23:07:46

你可以试试这个插件:http://wordpress.org/extend/plugins/view-own-posts-media-only/

或者试试这个:

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;
}

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