我在wordpress多站点中工作,但这个问题与wordpress中的常规使用相关。
如何对某些用户组(例如,编辑或管理员)隐藏某些侧栏?我已经尝试过一些琐碎的事情:
if(is_admin() && user_can(...)){
register_sidebar...
}
但这并没有隐藏侧边栏,它表明这个侧边栏并没有处于活动状态,因此,编辑器仍然可以根据自己的意愿拖入或拖出。谢谢
我在wordpress多站点中工作,但这个问题与wordpress中的常规使用相关。
如何对某些用户组(例如,编辑或管理员)隐藏某些侧栏?我已经尝试过一些琐碎的事情:
if(is_admin() && user_can(...)){
register_sidebar...
}
但这并没有隐藏侧边栏,它表明这个侧边栏并没有处于活动状态,因此,编辑器仍然可以根据自己的意愿拖入或拖出。谢谢
我假设您的意思是限制访问权限,以编辑管理界面中的侧栏,而不是删除它的主题。
如果不深入了解小部件/侧栏框架在幕后的工作方式,那么最好的选择就是$wp_registered_sidebars
全球的然而,关键是当时间太早和wp管理/小部件时。php模板将看到缺少的侧栏,并将其移到非活动侧栏“侧栏”。太晚了,而且,你没有效果。
add_action(\'widgets_admin_page\', \'sidebar_capabilities\');
/**
* Keep in mind that you can certainly create custom
* capabilities for your sidebars. You could create a loop
* that generates new capabilities for each sidebar and assigns them
* to admin. You could then manage those capabilities for other
* users with the Members plugin by Justin Tadlock
*/
function sidebar_capabilities(){
global $wp_registered_sidebars;
//Remove the comment lines to see the global variable structure.
//print_r($wp_registered_sidebars);
//Use whatever capabilities you want.
//To test as admin, just put junk text for the cap.
if(is_admin() && !current_user_can(\'edit_plugins\')){
//This sidebar name is from the twenty-ten theme.
unset($wp_registered_sidebars[\'primary-widget-area\']);
}
}
因此,我目前正在运行一个多站点安装,超级管理员将创建所有新站点。我们使用的其中一个模板有一个贷款官员的博客页面。我正在扩展用户配置文件,以便新用户可以输入需要在其页面上显示的关键数据。除了创建站点时自动添加的超级管理员之外,每个站点只有一个用户。我发现,如果要使用该函数,需要指定用户IDthe_author_meta(); 循环外部。这是我的问题。我无法在模板中输入ID,因为每个新的贷款官员都将使用相同的主题模板。那么,如何使这些字段成为动态的呢?下面是配置文件部分的图像,以便LO在视觉上有所帮