Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have the following function which alows me to set a post author, even if they are only a subscriber:

add_filter('wp_dropdown_users', 'MySwitchUser');
function MySwitchUser($output)
{

    //global $post is available here, hence you can check for the post type here
    $users = get_users('role=subscriber');

    $output = "<select id=\"post_author_override\" name=\"post_author_override\" class=\"\">";

    //Leave the admin in the list
    $output .= "<option value=\"1\">Admin</option>";
    foreach($users as $user)
    {
        $sel = ($post->post_author == $user->ID)?"selected='selected'":'';
        $output .= '<option value="'.$user->ID.'"'.$sel.'>'.$user->user_login.'</option>';
    }
    $output .= "</select>";

    return $output;
}

The subscribers can create posts from the front end of the site, but in some cases the admin will need to go into the post and update a few things via the wp backend.

When the admin updates and publishes the post, the post author will change from the originally post_author to the admin.

Is there a way i can get around this?

share|improve this question
    
    
Can you explain why? –  dan Jan 22 at 11:52
    
Under what circumstances does this occur? I don't recall ever noticing this behavior, and I just tested with a draft post and the author did not change when an admin published it. –  s_ha_dum Jan 22 at 14:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.