WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] author permissions (5 posts)

  1. kopa
    Member
    Posted 9 years ago #

    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.

  2. kopa
    Member
    Posted 9 years ago #

    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;
    }
    }

  3. kopa
    Member
    Posted 9 years ago #

    users with same userlevel can get to the edit screen, but then they are not allowed to save the updated post. :-(

  4. trombone
    Member
    Posted 9 years ago #

    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;
    }

  5. trombone
    Member
    Posted 9 years ago #


Topic Closed

This topic has been closed to new replies.

About this Topic