Guest User

Untitled

a guest
Aug 15th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. register_meta('post', 'idToPreserve', array(
  2. 'type' => 'integer',
  3. 'description' => 'Id to save to the db',
  4. 'single' => true,
  5. 'show_in_rest' => true
  6. ));
  7.  
  8. register_meta('post', 'idToDiscard', array(
  9. 'type' => 'integer',
  10. 'description' => 'Id we use only temporarily.',
  11. 'single' => true,
  12. 'show_in_rest' => true
  13. ));
  14.  
  15. add_action('added_post_meta', 'doThing', 10, 4 );
  16.  
  17. public static function doThing($meta_id, $object_id, $meta_key, $_meta_value) {
  18. if ($meta_key !== 'idToDiscard) return;
  19. //Do Things
  20. }
  21.  
  22. public static function remove_custom_meta($post, $data, $update) {
  23. return delete_post_meta($post->ID, 'idToDiscard');
  24. }
Add Comment
Please, Sign In to add comment