author permissions
-
i would like to give authors with same userlevels edit-privileges for their posts. i can’t finde the function where i should change the default behaviour. would be nice if someone could hint me to the right direction.
thanks konrad.
-
ok – i found the function:
/wp-includes/functions_post.php:/* returns true if $user_id can edit $post_id */
function user_can_edit_post($user_id, $post_id, $blog_id = 1) {
$author_data = get_userdata($user_id);
$post = get_post($post_id);
$post_author_data = get_userdata($post->post_author);if ( (($user_id == $post_author_data->ID) && !($post->post_status == ‘publish’ && $author_data->user_level < 2))
|| ($author_data->user_level > $post_author_data->user_level)
|| ($author_data->user_level >= 10) ) {
return true;
} else {
return false;
}
}change to:
/* returns true if $user_id can edit $post_id */
function user_can_edit_post($user_id, $post_id, $blog_id = 1) {
$author_data = get_userdata($user_id);
$post = get_post($post_id);
$post_author_data = get_userdata($post->post_author);if ( (($user_id == $post_author_data->ID) && !($post->post_status == ‘publish’ && $author_data->user_level < 2))
|| ($author_data->user_level >= $post_author_data->user_level)
|| ($author_data->user_level >= 10) ) {
return true;
} else {
return false;
}
}users with same userlevel can get to the edit screen, but then they are not allowed to save the updated post. 🙁
You also need to edit the functions: user_can_edit_user() in the same file from:
function user_can_edit_user($user_id, $other_user) {
$user = get_userdata($user_id);
$other = get_userdata($other_user);
if ( $user->user_level > $other->user_level || $user->user_level > 8 ||
$user->ID == $other->ID )
return true;
else
return false;
}to
function user_can_edit_user($user_id, $other_user) {
$user = get_userdata($user_id);
$other = get_userdata($other_user);
if ( $user->user_level >= $other->user_level || $user->user_level > 8 ||
$user->ID == $other->ID )
return true;
else
return false;
}
- The topic ‘author permissions’ is closed to new replies.