Get names of authors who have edited a post

How can I call the usernames of people that have edited a post?

I know I can use get_the_modified_time to display the time the post was last modified, is the same possible with the list of users that edited it?

Related posts

1 comment

  1. The WordPress function get_the_modified_author() will give you the
    author who last edited the current post.

    But if you want to list all the users that have edit the current post, you could try:

    function get_the_modified_authors_wpse_99226(){
        global $wpdb;
        $authors = array();
        $results = $wpdb->get_results( $wpdb->prepare("SELECT post_author FROM $wpdb->posts WHERE (post_type = '%s' AND ID = %d) OR (post_type = 'revision' AND post_parent = %d) GROUP BY post_author", get_post_type( get_the_ID() ), get_the_ID(), get_the_ID() ) );
        foreach($results as $row){
              $authors[] =  get_the_author_meta('display_name', $row->post_author );
        }
        return implode(", ", $authors);
    }
    

    This function will give you a distinct comma seperated list of the users that have edit the current post (i.e. their display name). This should also work with custom post types.

Comments are closed.