get_the_modified_author( int|WP_Post|null $post = null ): string|null

Retrieves the author who last edited the current post.

Parameters

$postint|WP_Post|nulloptional
Post ID or post object. Default is global $post object.

Default:null

Return

string|null The author’s display name. Empty string if user is unavailable. Null if there was no last editor or the post is invalid.

More Information

Usage:
<?php echo get_the_modified_author(); ?>

Source

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 : '' );
}

Hooks

apply_filters( ‘the_modified_author’, string $display_name )

Filters the display name of the author who last edited the current post.

Changelog

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

User Contributed Notes

You must log in before being able to contribute a note or feedback.