get_the_modified_author()WP 2.8.0

Gets the name (display_name) of the user (author) who last edited the current post.

Used on pages of type is_singular().

1 time — 0.000051 sec (very fast) | 50000 times — 1.22 sec (fast) | PHP 7.0.8, WP 4.6
Hooks from the function

Returns

String|null. The name of the site user. Will return NULL if there is no data about the last edit stored in the meta-field of the post: '_edit_last'.

Usage

$author_name = get_the_modified_author();

Examples

0

#1 Display the name of the author who edited the post last

This code is supposed to be used on pages like is_singular().

<?php echo get_the_modified_author(); ?>

Changelog

Since 2.8.0 Introduced.
Since 6.9.0 Added the $post parameter. Unknown return value is now explicitly null instead of void.

get_the_modified_author() code WP 7.0

function get_the_modified_author( $post = null ) {
	$post = get_post( $post );
	if ( ! $post ) {
		return null;
	}

	$last_id = get_post_meta( $post->ID, '_edit_last', true );
	if ( ! $last_id ) {
		return null;
	}
	$last_user = get_userdata( $last_id );

	/**
	 * Filters the display name of the author who last edited the current post.
	 *
	 * @since 2.8.0
	 *
	 * @param string $display_name The author's display name, empty string if user is unavailable.
	 */
	return apply_filters( 'the_modified_author', $last_user ? $last_user->display_name : '' );
}