|
魔扣币兑换比例:【 50以下 : ¥1 = 10 魔扣币 】丨【 50 - 100 :¥1 = 20 魔扣币】丨【 100以上:¥1 = 30 魔扣币 】
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?立即注册
x
有时候我们给用户后台发布的权限,可是不想让用户看到所有的媒体库,可以使用View Own Posts Media Only插件,也可以在当前主题的 functions.php 文件添加下面的代码:
- //在文章编辑页面的[添加媒体]只显示用户自己上传的文件
- function MBT_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','MBT_my_upload_media');
- //在[媒体库]只显示用户上传的文件
- function MBT_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', 'MBT_my_media_library' );
复制代码 下载:点击下载
|
|