【问题标题】:Customizing Admin Panel in WordPress for selected users在 WordPress 中为选定用户自定义管理面板
【发布时间】:2023-03-24 02:15:01
【问题描述】:

首先,我是 wordpress 新手,我在 wordpress 中创建了一个应用程序。我正在使用一个插件,现在在该插件中针对特定角色(例如学生、教师站点)进入管理面板。

现在,我想为学生和教师等选定用户自定义管理面板的外观。我已经尝试过“AG Custom Admin”,但并不完全满意。所以,我想制作自定义 css。

有没有什么办法可以像,

if(is_admin())
{
    // Use Default CSS
}
else
{
    // My Custom CSS
}

如果是,那么我在哪里可以使用此条件?我正在使用 wordpress 3.8

任何帮助都会非常明显,

谢谢。

【问题讨论】:

    标签: php wordpress customization


    【解决方案1】:

    检查 current_user_can() 方法:
    http://codex.wordpress.org/Roles_and_Capabilities#Capabilities

    这个方法可以这样使用:

    if ( current_user_can('moderate_comments') ) {
        wp_enqueue_style( 'Teacher Styles', 'teacherStyles.css' );
    }
    else{
        wp_enqueue_style( 'Default Styles', 'defaultStyles.css' );
    }
    

    【讨论】:

    • 查看我发布的链接。有一个具有不同用户角色/权限的表。根据用户的角色,您可以调整样式表。
    猜你喜欢
    • 2012-09-26
    • 2015-05-07
    • 1970-01-01
    • 2010-12-23
    • 2021-11-19
    • 2020-05-24
    • 2018-11-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多