您需要在标题中定义类似的内容。php文件。
<?php
if ( is_user_logged_in() ) {
echo \'Welcome, registered user!\';
} else {
echo \'Welcome, visitor!\';
}
?>
使用以下代码创建一个新角色,并将其放入函数中。php
add_role(\'partners\', \'Partners\', array(
\'read\' => true, // True allows that capability, False specifically removes it.
\'edit_posts\' => true,
\'delete_posts\' => true,
\'edit_published_posts\' => true,
\'publish_posts\' => true,
\'edit_files\' => true,
\'import\' => true,
\'upload_files\' => true //last in array needs no comma!
));
现在让我们假设您的合作伙伴具有“编辑发布的帖子”的功能。您可以这样定义菜单。
<?php
if ( is_user_logged_in() ) {
if(current_user_can(\'edit_published_posts\')) {
echo \'Welcome, Partner!\';
}
else {
echo \'Welcome, registered user!\';
}
}
else {
echo \'Welcome, visitor!\';
}
?>