I have multiple users. Some are writers, others are editors. Is there a way to get the editor (id) that publish the post?

I am able to get the author id but the not the editor’s id that publish the article.

Read more here: How can I get the user that publishes a post?


Solution:

I am not sure if that is built in, but you can try adding something like this to your functions.php

    function set_publisher( $new_status, $old_status, $post ) {
          $publisher_id = get_current_user_id();
          if (  $new_status == 'publish' && $publisher_id > 0) {
              update_post_meta($post->ID, 'post_publisher', $publisher_id);
          }
     }
     add_action( 'transition_post_status', 'set_publisher', 10, 3 );

And then when you want to get the publisher you use

$publisher = get_user_by('id', get_post_meta(get_the_ID(), 'post_publisher', true));

Related Wordpress search:

, ,

Wordpress related questions and answers: