Site icon Hip-Hop Website Design and Development

The right way to change the publish creator when the publish is revealed?

I needed to alter the creator when a publish change from draft to publish. I’ve $_GET['auth_id'] variable in publish edit display screen like this ...wp-admin/publish.php?publish=53&motion=edit&auth_id=5. I attempted save_post hook to alter the publish creator like under

perform change_pos_auth($post_id){
        if ( ! wp_is_post_revision( $post_id ) ){

    // unhook this perform so it does not loop infinitely
    remove_action('save_post','change_pos_auth');

   if ( isset($_GET['auth_id']) ) {
        $args = array('ID'=>$post_id,'post_author'=>$_GET['auth_id']);
    // replace the publish, which calls save_post once more
    wp_update_post( $args );
   }

    // re-hook this perform
    add_action('save_post','change_pos_auth');

}
}

This does not work out could also be this won’t have $_GET variables. I attempted the get the present person to make them because the creator

perform change_pos_auth($post_id){
        if ( ! wp_is_post_revision( $post_id ) ){

    // unhook this perform so it does not loop infinitely
    remove_action('save_post','change_pos_auth');
   if ( $last_user = get_post_meta( $post_id, '_edit_last', true) ) {
        $args = array('ID'=>$post_id,'post_author'=>$last_user);
    // replace the publish, which calls save_post once more
    wp_update_post( $args );
   }

    // re-hook this perform
    add_action('save_post','change_pos_auth');

}
}

Above additionally does not work. The principle thought is that, it’s a query & reply sort. the creator who first reply the query in admin turns into the creator of the publish. Query will probably be requested by admin by default.So i am making an attempt to alter the creator on save when it will get revealed. If the publish is revealed already am not permitting different authors to the edit display screen. I will redirect to a different web page and say somebody answered it already.

Any Assist?