对于我所使用的特定用户名的权利:
//give the right to deactivate sites to 'username' if the user doesn't have it already
$user = new WP_User('username');
if (! $user->has_prop('can_manage_sites')) {
$user->add_cap('can_manage_sites');
}
if (! $user->has_prop('username')) {
$user->add_cap('manage_sites');
}
//ofcourse replace 'username' with the username you need
在我看来,我只是使用if语句来检查网站是否激活或不知道要使用哪个链接(激活/停用)
//deactivated, show activate link
if(get_blog_status($site->blog_id, 'deleted') == '1'){
echo '<span class="dashicons dashicons-no" style="color:red;"></span> Niet actief <br/>';
echo '<a href="' . esc_url(wp_nonce_url(network_admin_url('sites.php?action=confirm&action2=activateblog&id=' . $site->blog_id), 'activateblog_' . $site->blog_id)) . '">' . __('Activate') . '</a>';
}
//activated, show deactivate link
else {
echo '<span class="dashicons dashicons-yes" style="color: green;"></span> Actief<br/>';
echo '<a style="color:red;" href="' . esc_url(wp_nonce_url(network_admin_url('sites.php?action=confirm&action2=deactivateblog&id=' . $site->blog_id), 'deactivateblog_' . $site->blog_id)) . '">' . __('Deactivate') . '</a>';
}
此代码会为您提供您需要的链接(de)激活网站,您将会看到一个确认页面。在此确认页面中,用户可以在菜单中看到一个'sites'标签,当他们点击它时有mu中所有网站的选项。这对我来说并不重要,因为将使用此功能的人是同事,并且知道他们不应该去那里。 但是你可能想要隐藏,如果它涉及那些不应该能够看到的人
检查是否可以帮助https://www.role-editor.com/wordpress-multisite-super-admin-特权/ –
谢谢。但那不是我想要实现的,我不想让这个角色访问'网络'部分。我只想显示每个mu上的(de)激活链接,对于该角色可见:) – Maartje
找到这两个动作功能:https://developer.wordpress.org/reference/hooks/deactivate_blog/和https:// developer .wordpress.org/reference/hooks/activate_blog /。现在我只是寻找一些功能或选项来查看该网站是否处于活动状态。就像is_active_mu? – Maartje