I'm searching (a) plug-ins for user role and rights. My idea is to have an user geek1 which can only manage the the maincategory 'geeks'. He should be able to create & manage new subcategories, pages and posts. But all new entries have to be assigned at minimum to his maincategory 'geeks'. The next user is freak1 and has a maincategory 'freaks'. He should have the same behaviours than geek1 but with his main category. And so on with other users. Do any one have an idea - or should I make my own plug-in?
The most powerful wordpress plugin for role management is "Role Scoper". A more light-weight alternative would be "Members".
If neither one of these two meets your requirements, look no further - then there isn't one.
You'd have to either write your own plugin or add the required functionality to your theme's functions.php
. You'd have to make use of the global variable $current_user;
and check it either for role presence, usernames or user IDs. A snippet to get you started:
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
}
}
The pre_get_posts
action might be a good one to hook into.