save_post is an action triggered whenever a post or page is created or updated, which could be from an import, post/page edit form, xmlrpc, or post by email. The data for the post is stored in $_POST, $_GET or the global $post_data, depending on how the post was edited.

learn more… | top users | synonyms

0
votes
0answers
30 views

A correct hook for saving meta boxes data

Nothing happens when I do the var_dump() in a callback on post save. Here are the hooks I've tried: save_post as shown in the codex pre_post_update as suggested here wp_insert_post_data found in ...
0
votes
0answers
23 views

save_post is not firing when I only edit custom meta fields

I've come across the action hook save_post few days back and I like to take advantage of it. I've custom post post type "Property" with Meta fields associated with it. The problem is that when I ...
0
votes
0answers
64 views

Not Able to Display Metabox Saved Checkbox and Selected option After Save/ Update

am using this code to create a Metabox for CPT. Now I am able to view the updateded / saved Text input on post but the Checkbox and selected options return null after save or update. Can you please ...
3
votes
1answer
72 views

Is it possible to save/modify a post without calling the “save_post” action hook?

There is a save_post hook that is run when you save a post. In fact, revisions and autosaves also call this hook. Even if you simply change the status from published to draft it triggers the save_post ...
0
votes
0answers
30 views

wp_set_object_terms bugging

I'm working on a plugin where I set custom terms for posts on save. I use the save_post hook. It all works fine except when I for example also change the title of the post, the custom terms setting ...
0
votes
0answers
42 views

unwanted redirect on saving custom post type / custom post not saving

I've added (or at least attempted to add) a custom post type that has a custom meta box allowing a file to be attached to the post. This function has been spotty at best, allowing some files to be ...
0
votes
2answers
27 views

My custom title gets duplicated at every save or post update

I have a problem, my custom title keeps getting added at every time I save the post.. First I created a Custom Post Type called 'imac' plus a front-end form for posting in this Post Type, only before ...
0
votes
0answers
35 views

save_post action not firing due to old page_template meta data

I have some functionality hooked to the save_post action that wasn't working for a user on a particular WordPress Page. After some digging I found that wp_insert_post() was returning before getting ...
-1
votes
1answer
54 views

Save post to category with gravity forms (post_data) [closed]

I'm trying to save my posts, generated with gravity forms, to a specific category. However whatever I try, it's not working. The post must be saved to sepecific category, dependent from a gravity ...
0
votes
1answer
41 views

save_post not called in plugin / custom field still saving overwriting metaboxes

I have a plugin that writes metaboxes to certain pages. It writes the metaboxes fine and everything works as should...until I save. The save_post is not getting called, and I can't figure out why. ...
0
votes
1answer
175 views

Second select list values are not saved after clicking update

I have a select list in a metabox which value is saved successfully after clicking "Update" when editing post. Of course, the values are custom taxonomies. But i don't know how to add another select ...
0
votes
1answer
63 views

Save data of select list after clicking save

I already have a meta box in the edit post that has a select list with custom taxonomies. But after i save the post the select list returns it value to none, so i don't know how to save the selected ...
0
votes
0answers
97 views

Meta data not saved on save_post

When I try to save my post after inserting it via an external php script, it returns my the post id, but it's not able to retrieve the post meta created in the database. I am getting an array having ...
0
votes
1answer
236 views

How to store the value of a custom field dropdown select for post referencing?

I'm trying to reference posts to each other. Editors should have a custom field select list of certain post's titles to link the current post with other posts. I got quite far, I think. The select ...
0
votes
1answer
254 views

wp_insert_posts Fatal error: Maximum function nesting level of '100' reached, aborting!

I'm having a weird problem I have written the code as below: add_action('save_post', 'save_post_func'); function save_post_func(){ include_once(ABSPATH . WPINC . '/feed.php'); $rss = ...
0
votes
1answer
24 views

get categories the post was in and just been removed from

I have a function hooked to the save_post hook. this function is mostly concerned with the categories that the post is in. My function does the following: function post_save_hook($post_id){ ...
0
votes
0answers
82 views

Saving metadata of related post on save_post

here is the scenario: Custom Post Type "shows" Custom Post Type "reviews" Reviews are "child" of shows so that every review has a custom field with the ID of the parent "show". Since a review has ...
0
votes
2answers
101 views

Save checkboxes of a metabox with a foreach loop (invalid argument)

I'm new to Wordpress plugin development and I'm trying to create a list of checkboxes (from a WP Query) to associate as custom fields for a specific post type. Nothing wrong with the display function, ...
0
votes
1answer
26 views

Can't Get Metabox Data Saved Assistance Needed

I'm trying to create meta box on a post create/edit page. I faced the problem: 1. When I create a post from scratch the data from my meta box is saved as expected 2. When I try to update an existing ...
0
votes
1answer
49 views

Strange bug on post/page save

I have a srtange bug when I try to save/update a post. Every time I got this alert: "Are you sure to live this page?...." I've switched tothe original theme, disabled almost all plugins but nothing ...
0
votes
1answer
116 views

How to change the post author when the post is published?

I wanted to change the author when a post change from draft to publish. I have $_GET['auth_id'] variable in post edit screen like this ...wp-admin/post.php?post=53&action=edit&auth_id=5. I ...
0
votes
1answer
97 views

save_post action not firing when save

Below is my code that will take the post_id and randomly get 3 posts from the same category and store them as custom field. The code is clearly working, because when I click "New Post", I see the ...
0
votes
0answers
87 views

post_content not parsed using save_post action hook

A site I'm building for a client has to be able to download Vine's to a server when they've been posted using a shortcode ([vine id="..."]). This works fine for my local install (it's a Multisite ...
0
votes
1answer
139 views

How to get post bulk edit action trigger and get edited post ids?

I want to send email if a postmeta of a post is changed to the expected value.So previously i was doing loop to check the post meta in each post. In here am running the loop in admin_init hook. But ...
0
votes
0answers
50 views

save_post hook frustration

Clean 3.8.1, clean Twenty Fourteen theme, no plugins except for my own custom one. The main plugin PHP file only has a single "require_once('test.php')" And "test.php" in its entirety is: ...
1
vote
1answer
2k views

Remove empty lines ( ) when author updates their post

Whenever adding an empty line between paragraphs using TinyMCE, the   character entity is added. How can I strip the content of all instances of this character whenever an author updates ...
0
votes
1answer
47 views

About WP's save_post action

Quick question, in API's some times save_post is used(most of the time actually). Is save_post the equivalent of the query action INSERT INTO whereas save_post saves metadata and forces Wordpress to ...
0
votes
0answers
14 views

Disable a function from executing in post.php

I have a function that seems to execute on saving a post (post.php) and I would to disable it from executing then. I don't know how to specify that? I could check if is_admin, but that would disable ...
0
votes
0answers
344 views

Function that get ACF fields value before saving

Rewrited question: There is a similar question HERE but I don't know how to combine it with my code. I have a function that relay on acf checkbox field. It is working fine but I have to update the ...
0
votes
1answer
281 views

Wp_update_post: Infinite loop even with remove_action solution, OOP

I have a quite complex PHP class, reponsible for creating and printing meta_boxes, generating and saving meta fields, ... Each meta_box (object of class) has its own save function, that updates meta ...
0
votes
2answers
330 views

what is correct way to hook when update post

i try to hook when post is updated but all hook i try never executed except updated_post_meta add_action('updated_post_meta', 'my_function'); function my_function($post_id) { echo 'This is ...
0
votes
0answers
31 views

Deregister or disable duplicate check ($post_exists) in cpt saving/updating process

I have registered a custom post type which is ment to bring up 24 posts a year, titles only containg numbers 1-24. I did some rewrites to achive that the permalink structure of this posts will be ...
0
votes
1answer
439 views

Can wp_insert_post_data filter be used to save custom field data?

I have custom field data that I would like to modify on its way to the database. wp_insert_post_data filter seems to be the closest thing I can find to achieving this. I dumped the $data and $postarr ...
0
votes
1answer
212 views

Return code from save_post action?

I'd like to understand what value I should return from a WordPress save_post action function. This example from the save_post documentation both explicitly and implicitly returns without a value: ...
0
votes
1answer
37 views

Insert/Update DB table when making new post or update older one

I was wondering how can I insert a DB row (not related to WordPress tables) only when I update or add a new post. Right now I have this... add_action( 'save_post', 'insertIntoDBatPost'); function ...
0
votes
1answer
18 views

What is the proper way to add a required field to a post type? [duplicate]

So I created a CPT that has a few required fields in a metabox. My metadata is being saved through the save_post hook but from I can find via my googlefu there is no way to stop the saving of the post ...
3
votes
1answer
70 views

Disallow a user to post in certain categories

I am writing a plugin that will disallow user to post in certain categories. I am trying to display an error message to the user when he tries to post in the restricted category and also want WP ...
1
vote
1answer
1k views

update_post_meta() whenever custom post type is updated

I need the following functionality. Whenever my custom post type is updated or saved I need to overwrite certain custom post metas. I need to make sure this only affects posts of the post type ...
0
votes
2answers
988 views

post_status => publish not working

I have a front end form that let users submit a post. This is how i store the data when a post is submitted : if ( isset( $_POST['submitted'] )) { $post_information = array( ...
0
votes
1answer
234 views

Why does not my metabox save?

I know there are many questions about variants of this, but I have not been able to find an answer. I have a metabox on the post type page, containing nothing but a checkbox. It seems like it won't ...
1
vote
1answer
562 views

Updating the database with advanced custom fields

I'm having a real problem with updating a database table using advanced custom fields within a custom post type. I have a table in the database called 'wp_company_profiles' with fields 'address_1' ...
1
vote
0answers
88 views

Wordpress custom admin notice still displays after wp_insert_post_data validation

I am trying to validate post data before saving, specifically checking to see if an image exists within the first 750 characters of the post content. The code below works and display the admin notice ...
0
votes
0answers
74 views

WP Infinite loop

It is not working. add_action( 'save_post', 'jdev_save_custom_meta_box', 13, 2 ); function jdev_save_custom_meta_box(){ global $post; // Get our form field if( $_POST ) : if ( ...
0
votes
1answer
437 views

Execution of JavaScript on save post

I got stuck with one problem, can somebody please help.. :) I would like to execute custom JavaScript function before post is saved, and i can't find how to do that. Something like JavaScript version ...
0
votes
0answers
72 views

wordpress meta_box data don't save

I made this metabox with an input item and two select items(a dropdown and a checkbox). When i write something in the input item or i select something it disappear when i update the post. Another bug: ...
0
votes
1answer
1k views

update_post_meta and update_field ony working when saving the post

I use Advanced Custom Fields (ACF) to store data in a custom field. I had latitude and longitude information stored separately, but I they need to be in one custom field so I made the function below. ...
1
vote
1answer
687 views

save_post action firing before I publish / save the post

I'm trying to update a posts meta only after it has been saved or updated. My function is pretty simple function update_test( $post_id ) { update_post_meta($post_id, 'copied', '1'); ...
0
votes
1answer
83 views

draft_to_pending action doesn’t seem to fire

I have the action ‘draft_to_pending‘ set to fire on a custom post type. I assume that when the user clicks “Status » Edit” changes it to “Pending” and then clicks “Save Pending”, this action is ...
2
votes
2answers
276 views

How to force function to run as the last one when saving the post?

I don't know how to force this function to run as the last function after all other save things from WP are executed. This is my current code in my plugin: add_action( 'save_post', 'do_custom_save' ...
0
votes
2answers
37 views

What action to use for when a post is saved / published, with a caveat

I'm trying to do some stuff when a post has been saved, I'm currently using the save_post action, of which generally works. However, the problem I'm having is when a post is scheduled it fires the ...