【问题标题】:How to hide or remove MEDIA LINK TO settings?如何隐藏或删除 MEDIA LINK TO 设置?
【发布时间】:2015-04-15 08:59:26
【问题描述】:

我想在 WORDPRESS 中为作者禁用 MEDIA LINK TO 设置。我尝试了以下代码,但作者仍然可以更改设置。

add_action( 'print_media_templates', function(){
    echo '<style>.post-php select.link-to option[value="post"] {display:none;}</style>';
});

我尝试使用 display:none 之类的 CSS 技巧,但它也不起作用。有什么办法吗?

【问题讨论】:

    标签: wordpress attachment options


    【解决方案1】:

    试试下面的代码:

    add_action( 'admin_init', 'remove_media_menu_pages' );
    function remove_media_menu_pages() {
    
        if ( is_user_logged_in() )
        {
            $user_ID=get_current_user_id(); //Get current user id
            $user = new WP_User( $user_ID );
    
            if ( !empty( $user->roles ) && is_array( $user->roles ) )
            {
                foreach ( $user->roles as $role )
    
                if($role == 'author') {
            // Remove the "Media" Menu from the list
                remove_menu_page('upload.php');
    
                }
            }
        }
    
    
    }
    

    【讨论】:

      猜你喜欢
      • 2021-02-16
      • 1970-01-01
      • 2017-09-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-09-24
      • 2012-07-16
      • 2021-01-18
      相关资源
      最近更新 更多