[wp-trac] [WordPress Trac] #50255: get_the_modified_author() not working

WordPress Trac noreply at wordpress.org
Tue May 26 14:16:36 UTC 2020


#50255: get_the_modified_author() not working
---------------------------+-----------------------------
 Reporter:  stilldreaming  |      Owner:  (none)
     Type:  defect (bug)   |     Status:  new
 Priority:  normal         |  Milestone:  Awaiting Review
Component:  General        |    Version:  5.4.1
 Severity:  normal         |   Keywords:
  Focuses:                 |
---------------------------+-----------------------------
 It seems that get_the_modified_author() is not working.

 Looking at the source code of the function I noticed that the _edit_last
 meta field is not filled for the specific post, even though the post was
 edited.

 After a closer look it seems that _edit_last is not in the meta data for
 regular posts and for pages (though I noticed it was there for the
 standard privacy page). It is there for custom posts.

 So it seems that get_the_modified_author() is not working for pages and
 regular posts.

 I looked at wp_check_post_lock() and saw that this function takes another
 approach. It looks at the _edit_lock field. This field is still there
 after the editing is over.

 So, this piece of code works for pages, posts and custom posts:

 {{{#!php
 <?php
 function abc_get_user_id( $post_id ) {

     $lock = get_post_meta( $post_id, '_edit_lock', true );
     if ( ! $lock ) {
         return 0;
     }
     $lock = explode( ':', $lock );
     $time = $lock[0];
     $user = isset( $lock[1] ) ? $lock[1] : get_post_meta( $post->ID,
 '_edit_last', true );

     return $user;
 }
 }}}

 In this case the user who modified the page/post is part of another field,
 which makes it harder to filter for that.

 My suggestion would be to make _edit_last work again, or have a specific
 field in the post object, just like post_modified and post_modified_gmt
 that are used for the modification date/time. This would make it easier to
 filter also.

 The functions get_the_modified_date() and get_the_modified_time() are
 working correctly.

 I have tested this on WP 5.4.1

 This was discussed in the forum here:
 https://wordpress.org/support/topic/get_the_modified_author-not-working/

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/50255>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list