I need to trigger a function everytime the user save the post manually (so only thanks to the “Update button”).
Here’s what I have :
add_action( 'save_post', 'my_save_post_function', 10, 3 ); function my_save_post_function($object_id, $post, $updated) { $post = get_post($object_id); $post_ID = $object_id; if(!wp_doing_ajax() && count($_REQUEST) > 2){ if($post->post_type == "incsub_event" && $_POST["action"] = "editpost") { /* do stuff*/ } }
Problem : this function is trigger twice (I can see that thanks to my code in do stuff, everything is dupplicated).
Seems like the first time is triggered when the user click on the link, and the second time (maybe ?) after the metadata are updated.
How can I trigger this only once ?
PS : tried with hook “post_updated” (doesn’t update my metadata) and “update_post_metadata” (triggers twice too)
- State NFL roundup: Philip Rivers sets all-time NFL accuracy mark
- Montana State's Tyler Hall sets all-time scoring record
- Boston sets all-time temperature record for Dec. 21
- Thanksgiving 2018: Air travel could set all-time record for the holiday
- Sabrina Ionescu sets all-time Div. I triple-double record as Oregon beats Air Force 82-36
- Panthers capture Bahamas Bowl, set all-time win record
- Trump sets prime time address Tuesday to pitch border wall, and border visit Thursday
- Triggering a Time Trap
- Trigger Warning is a Paranoid Right-Wing Laugh Riot
- Remembering Sandy Hook on its 6th year anniversary, vigil to be held Friday