有谁知道如何在管理员的 WordPress 网站上发布帖子后隐藏出现的帖子发布消息。
我已经看到这个例子向除管理员之外的所有人隐藏更新可用消息,但我不确定需要添加什么来删除保存消息:
function hide_update_notice_to_all_but_admin_users()
{
if (!current_user_can('update_core')) {
remove_action( 'admin_notices', 'update_nag', 3 );
}
}
add_action( 'admin_head', 'hide_update_notice_to_all_but_admin_users', 1 );
Run Code Online (Sandbox Code Playgroud)
我需要删除常规帖子和自定义帖子类型上的消息。据我所知,这应该只是替换的情况,'update_nag'但我不确定用什么替换它。
谢谢
我希望根据多个不同的用户角色显示内容。
目的是为两个或三个不同的用户角色显示内容,然后为其他用户角色阻止它,显示一条消息,它仅适用于某些登录用户。
到目前为止,我有以下几点:
<?php
global $user_login, $current_user;
get_currentuserinfo();
$user_info = get_userdata($current_user->ID);
$roles = array (
'administrator',
'subscriber',
);
if (is_user_logged_in() && in_array( $roles, $user_info->roles)) {
//content here
} else {
// they aren't logged in, so show them the login form
}
?>
Run Code Online (Sandbox Code Playgroud)
目前,我遇到的问题似乎是代码同时查找管理员和订阅者角色,因此不满足 if 语句并显示登录表单。
如果我将 $roles 更改为“管理员”或“订阅者”,则它可以正常工作。
那么,我将如何搜索数组以显示任一角色,而不是所有角色。
谢谢