save_post trigerred twice
save_post trigerred twice
save_post trigerred twice
I don’t know what you want to do besides checking the meta so i’m gonna give a very basic example. function bt_check_saved_post_meta ($post_id) { if (!empty(get_post_meta($post_id, ‘some_meta’, true))) { // do something here } } add_action(‘save_post’, ‘bt_check_saved_post_meta’);
Access NEW/UPDATED post values in save_post() callback function
I think one key question here is how _select_match_from_id meta value is saved? Is it some metafield on the post edit screen or from some other logic? If I may assume that it is from a metafield, then you could just read its value from the $_POST array. You could also improve your code by … Read more
I am not entirely sure what you are trying to do. But you are definitely a little off with add_action(). Should be something like this: function myFunctionThatSendsMyWebsite($post_ID, $post) { // $post_ID and $post will have post’s ID and full post object } add_action(‘save_post’, ‘myFunctionThatSendsMyWebsite’, 10, 2);
here’s the complete code : if somebody could try it, i might doing something wrong, but i can’t find out what. (the whole code is inside a widget page) /* * * add meta box : habillage * */ add_action( ‘add_meta_boxes’, ‘myplugin_add_custom_box’ ); add_action( ‘save_post’, ‘myplugin_save_postdata’ ); /* Adds a box to the main column … Read more
Take a look at the Plugin API/Action Reference: Actions Run During an Admin Page Request.. Then add something simple to the appropriate hook: function wpse19260_inspect_post() { echo ‘<pre>’; // print_r( $_POST ); echo $_POST->ID; echo $_POST->post_content; echo $_POST->post_title echo ‘<pre>’; } add_action( ‘publish_post’, ‘wpse19260_inspect_post’ );
Figured it out: update_post_meta($id, ‘main_tag’, $_POST[‘mainTagButtons’]) Easy
Rather than ‘returning’ on a failure of authentication check, die with an appropriate message: For example: if ( !wp_verify_nonce( $_POST[‘states_noncename’], plugin_basename( __FILE__ ) ) ) wp_die(“Nonce-check failure”); This will indicate on what check (if any) that you are failing. In most cases, I would advise doing this rather than returning as it gives the user … Read more
The problematic line is this one: if (isset($_POST[“book_title”]) && $_POST[“book_title”] <> ”) update_post_meta($post->ID, “book_title”, $_POST[“book_title”]); That logic says: If the submitted form contains a field called ‘book_title’ and if the content of the ‘book_title’ field does not equal an empty string, then save it. In your situation, the first condition should be met (HTML input … Read more