WordPress keeps track of the author of the last modification.
I couldn’t find a plugin to do this, so you are going to have to modify how your Posts are displayed. Here is the complete set of documentation on the relevant PHP WordPress functions, including Template Tags, that you will need to use:
https://developer.wordpress.org/?s=modified_author
https://codex.wordpress.org/Function_Reference/the_modified_author
https://codex.wordpress.org/Function_Reference/get_the_modified_author
@jonradio – many thanks!
When I searched using terms like ‘update author on post modification’ this solution didn’t come up in Google, and it had not even occurred to me that WP would have a built-in way to track the modified_author, so I appreciate the direction – I’m sure I’ll be able to add this (as a column) to my post overview screen, I’ll post back with whatever snippet I come up with in case this helps someone else.
🙂
Well quite interestingly, my attempts to use the_modified_author and get_the_modified_author did not work, but I’ll keep playing around with that because I have a feeling I just wasn’t using them correctly and sadly the Codex does not contain any examples of how to use them.
BUT they did help me find this very old post, the solution provided there DID work perfectly for me:
https://wordpress.org/support/topic/last-author?replies=7
Basically it uses the _edit_last user ID to get the usermeta and display the name, it says that this code was incorporated into the template functions (above) so maybe if someone just provides examples of how to use the new template tags in the Codex it might help others to avoid having to do this the old way as I did.
SO for anyone looking to do this it’s important to note that I did NOT wind up *changing* the post author, but instead settled for displaying the person who last modified the post, which met our needs.
You can do something like this at the header or footer of your posts.
Published by <?php the_author();?> on <?php the_time(‘M j, Y’);?>
Updated <?php the_modified_date(‘M j, Y’); ?> by <?php the_modified_author(); ?>
Which will give you something like the following:
Published by Will Ribera on Sep 15, 2016 | Updated Nov 26, 2016 by Scott Fisher
Hi @smfisher…..thanks for chiming in, I did wind up solving this but was not able to use the_modified_author (it just wouldn’t show anything) – I’m not sure if that’s because I’m using it in a custom column on the Posts overview (admin) screen, not on a front-end Post (as it’s intended for public display), or the fact that I’m using it on a CPT.
In fact, *technically* on the posts overview screen, WP automatically updates and displays the author(user) who last touched a post IF it was modified and then saved, which means that on the posts overview screen you actually *lose* the original author(user), we needed to keep track of both, so now I have two columns, one for the original author who added the post, and one for whomever has changed it last (using _edit_last).
We’ll be giving this site a refresh in mid-2017 (updating everything) so I’ll revisit this at that time to see if I can use the_modified_author in my column population section where I add the extra column(s).
But at least for now it’s working fine using _edit_last.
🙂
You bet! I guess I didn’t read your post close enough… I found your post when I was trying to show modified author in my posts… I did add some more logic by the way. I will post this here incase you need it in the future… I wanted to display the publish date and author, and then check to see if any updates had been done and if so, display that author. We have to have accountability here to as this is our internal resource for constantly updated documents in the practice.
<!-- DISPLAY ARTICLE PUBLISH DATE AND AUTHOR -->
<?php _e( '<strong>Published </strong>' , 'knowall' ); ?>
<?php the_time('M j, Y');?>
by <a href="mailto:<?php print"$authordata->user_email";?>?subject=<?php the_title(); ?> Article in the KB"><?php the_author();?></a>
<!-- END CREATED DATE DISPLAY -->
<!-- DISPLAY LAST MOD AUTHOR INFO -->
<!-- WRAP IN AN IF STATEMENT SO WE DON'T SHOW THIS UNLESS THERE HAS BEEN A MODIFICATION -->
<?php if ( get_the_modified_time( 'U' ) > get_the_time( 'U' ) ) {
//echo 'Last updated:' . get_the_modified_time();
print "|";
print _e( '<strong>Updated</strong>' , 'knowall' );
print the_modified_date('M j, Y');
print "by"; the_modified_author();
}//else we don't show the above block -->
?>
<!-- END WRAPPED IF STATEMENT -->
<!-- END DISPLAY LAST MOD AUTHOR INFO -->
@smfisher, thanks for the followup and the code snippets – I’ve saved them in my ‘Quiver’ (literally, my Quiver code-storing app) for the future! I’m a compulsive code collector, so thank you!
Sweet, I will have to check out Quiver. I’ve been using dreamwever for as long as I can remember… It has a built in “snippets” panel. I may have to look at quiver though. 🙂
sf
-
This reply was modified 9 years, 5 months ago by
smfisher.