//在文章编辑页面的[添加媒体]只显示用户自己上传的文件function my_upload_media( $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_options' ) && !current_user_can('manage_media_library') )		$wp_query_obj->set('author', $current_user->ID );	return;}add_action('pre_get_posts','my_upload_media'); //在[媒体库]只显示用户上传的文件function my_media_library( $wp_query ) {    if ( strpos( $_SERVER[ 'REQUEST_URI' ], '/wp-admin/upload.php' ) !== false ) {        if ( !current_user_can( 'manage_options' ) && !current_user_can( 'manage_media_library' ) ) {            global $current_user;            $wp_query->set( 'author', $current_user->id );        }    }}add_filter('parse_query', 'my_media_library' );
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。