0

I am have a front-end new post and edit post forms.

  • I'll using the <?php wp_insert_post( $post ); ?>

Everything is all right here.

If any editor or admin modified any author posts on front-end: <?php the_modified_author(); ?> not working. But modified on /wp-admin administrator panel working it.

I want to update <?php the_modified_author(); ?> on my function! But how?

2

the_modified_author() displays the name of the user whose ID has been stored in the _edit_last post meta field.

If you want to update the ID after another user has updated the post, you can use something like update_post_meta( $post_ID, '_edit_last', get_current_user_id() );. Then the new user's name will be displayed when using the_modified_author().

Replace get_current_user_id() with a custom user ID if it's not the current user who's updating the post.

  • Thanks @swissspidy it work now. But I dont understand, Before you, If update post (front-end) I don't set the modified author! How work in the panel? And why not work front-end :) – lllllllllllll Jan 24 '18 at 18:17
  • In the admin area, other functions are used in addition to wp_insert_post(), which all call update_post_meta() manually. For example wp_restore_post_revision() and — most notably — edit_post(). I guess the reason is that wp_insert_post() is usually used for lots of other (automated) stuff not involving any users. So it doesn't make sense to update the user inside wp_insert_post() because the information might be wrong. Plus, you don't want that information stored for every post type. Thus, it needs to be done this way. – swissspidy Jan 24 '18 at 18:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.