用于角色管理的最强大的wordpress插件是“Role Scoper ". A more light-weight alternative would be " Members” .
如果这两者中的任何一个都不符合您的要求,那就不要再看了 - 那就没有了 .
你'd have to either write your own plugin or add the required functionality to your theme' s functions.php . 您必须使用全局变量 $current_user; 并检查它是否存在角色存在,用户名或用户ID . 一个让你入门的片段:
function restrict_current_user($query) {
global $current_user;
if ( in_array('substitute_the_user_role_here', $current_user->roles) ) {
// do stuff here
}
if ( in_array('substitute_the_user_name_here', $current_user->user_login) ) {
// do stuff here
}
// ID is an integer, no quotes around it:
if ( in_array(substitute_the_user_ID_here, $current_user->ID) ) {
// do stuff here
}
}
2 回答
用于角色管理的最强大的wordpress插件是“Role Scoper ". A more light-weight alternative would be " Members” .
如果这两者中的任何一个都不符合您的要求,那就不要再看了 - 那就没有了 .
你'd have to either write your own plugin or add the required functionality to your theme' s functions.php . 您必须使用全局变量
$current_user;
并检查它是否存在角色存在,用户名或用户ID . 一个让你入门的片段:pre_get_posts动作可能是一个很好的挂钩 .
这可能是旧闻,但是,您正在寻找的另一个选择可能是s2Member .
http://www.s2Member.com
他们有免费和付费的模型 . 请享用 .