Find out who deleted a page or post?

Someone moved a very important page on my website into the trash, and I do not know who did it! It was not deleted permanently so I don’t need to worry, in that sense.

The revisions, when I restored it, show that someone edited it 3 days prior to today, so it could have been them, but I can’t be sure.

Does WP keep track of who clicks the trash button? If not, I presume I’d have to write a custom script to hook onto the trash button, when clicked.

4 s
4

By default, no, WordPress doesn’t keep track of who changes post statuses (at least that I can see).

you can hook into transition_post_status and log the user id.

    add_action( 'transition_post_status', 'wwm_transition_post_status', 10, 3 );

    function wwm_transition_post_status( $new_status, $old_status, $post ) {
     if ( 'trash' == $new_status ) {
      $uid = get_current_user_id();
      //somehow or another log the $uid with the $post->ID
     }
    }

Leave a Comment