Advertisement
geminilabs

[site-reviews] Remove the author ID from reviews when saving

Sep 30th, 2019
417
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.39 KB | None | 0 0
  1. /**
  2.  * This removes the author (user) ID from an existing review when it is saved
  3.  *
  4.  * Paste this in your active theme's functions.php file.
  5.  * @return void
  6.  */
  7. add_action('save_post_site-review', function($postId, $post, $isUpdating) {
  8.     global $wpdb;
  9.     if ($isUpdating && $post->post_author != '0') {
  10.         $wpdb->update($wpdb->posts, ['post_author' => 0], ['ID' => $postId]);
  11.     }
  12. }, 10, 3);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement