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

2
votes
1answer
752 views

save_post hook not triggered in WP v3.6.1

I developed a plugin having a custom metabox that is using the save_post hook to store data. The plugin is 18 months old and is used by thousands of customers, so I'm pretty sure everything is good. ...
1
vote
1answer
780 views

pass error to admin_notices on “quick edit”/save_post action

I currently have add_action('admin_notices','my_notice_function'); updating correctly whenever a page is refreshed (it's checking if a certain page has a certain parent) but when using the "Quick ...
0
votes
1answer
959 views

save_post custom post type ? $_POST not working?

i have this code. <?php add_action('add_meta_boxes', 'ct_meta_add'); add_action('save_post','ct_meta_save'); add_action('save_post','ct_parent'); // add meta functions function ct_meta_add() { ...
1
vote
4answers
645 views

Updating wp_options with an array on save_post results in duplicated entries

I'm not entirely sure this is Wordpress' fault, but I figure I'd ask anyway and see if anyone else has experienced any problems like this before. I'm trying to save an array to a wp_options table ...
3
votes
2answers
35 views

Add post meta based on another post meta value before publish post

I want to add a meta value to my post , which will be based on another meta value , before publish post . This is what I have tried add_action('save_post_my_custom_post', ...
0
votes
0answers
26 views

Clone a Post Title and Custom Field to a CPT

I am using Simple Urls Plugin to setup redirects on my blog. I am trying to create redirects automatically upon publishing a post. For example, If i publish a post about StudioPress it will be ...
0
votes
1answer
854 views

save_post action inside a custom metabox class not working

I am writing a class to create metaboxes and save the form data. The problem is, I keep getting a warning when I click "publish": Warning: call_user_func_array() expects parameter 1 to be a valid ...
0
votes
0answers
15 views

My blog draft is cannot be saved. How do you save it without any failure?

I can't save my draft, as when i save it, it shows,'saving of draft failed'. How do i save my draft when this happens?
1
vote
1answer
535 views

Non-hierarchical custom taxonomy using checkboxes on edit-screen -> saving issue

I registered a non-hierarchical custom taxonomy ('property_features'). There is a checkbox for every terms of this tax in a custom meta box on the edit-screen. All terms are displayed and all terms ...
1
vote
2answers
617 views

Execute action after post is saved with all related post_meta records (data)

I have to execute custom PHP code after new post is saved with all it's meta data. My question is how to achieve that? Tried with save_post action, but it executes before meta records are saved, so I ...
0
votes
1answer
994 views

Auto save title as custom meta field value

I create a custom post type where I removed the "Title", instead I want to use one of my custom meta value to become the title. This is just to make sure the title look good. Know that the post ...
0
votes
1answer
14 views

save_post not triggered when a post is updated

I'm encountering something weird. I made a function on functions.php that I want to trigger when a post is saved or updated. function gh_set_inner_project_order($post_id){ $parent_id = ...
1
vote
2answers
31 views

$update is always true in save_post

I'm trying to fire some code only when a document type is created using save_post, but $update is always true, even when first publishing it. I assume this is because there's an autodraft created ...
6
votes
3answers
4k views

Using save_post to replace the post's title

I am using custom posts, and in these, I don't a need for the title. This causes Wordpress to set the titles of my posts to "Auto Draft". I'd like to change the title's value to something else, ...
3
votes
0answers
65 views

Hook to process a new taxonomy tag before it is created?

I am working on a website where there is a custom taxonomy for places, which can be either cities or states. The users are supposed to tag each post with a city and a state. To deal with ...
1
vote
1answer
18 views

Executing `createimagefrompng()` from save_post hook (or equivalent hook)

I'm having trouble executing createimagefrompng() from a hook. I've used the fairly straightforward PHP way to add a watermark to an image. If I hardcode the image URLs in this function and for ...
0
votes
2answers
72 views

Change auto post title generation according to different post properties

I have the following snippet that allows me to auto generate the post title. I'd like to change the $post_type of the 'post_title' => $post_type . ' Job #' . $post_id line to some other post ...
7
votes
5answers
10k views

Prevent post from being published if custom fields not filled

I have a custom post type Event that contains a starting and ending date/times custom fields (as metaboxes in the post edit screen). I would like to make sure that an Event cannot get published (or ...
1
vote
1answer
30 views

Undefined 'post_type' error on Add new page

I created a meta box for page see the following code: add_action('add_meta_boxes', 'add_metaboxes'); function add_metaboxes() { add_meta_box( 'wpt_slider_meta', 'Add Slider ...
0
votes
3answers
62 views

Updating user meta on save post

I have a custom post type called 'programmes' that details seminar information. Using a form visitors to the site can signup to a specific 'programme', once they have completed the form a new user is ...
2
votes
1answer
66 views

save_post action only when creating a new post

I have a Custom Post Type named Task. I created a function that sends an email to the selected Agent, notifying a new task has been assigned. Here is the function: function ...
0
votes
1answer
21 views

Using PODS data with save_post

I'm trying to use the save_post hook to send an SMS to a telephone number entered into a PODS custom post type. The SMS should be sent when the record is saved. add_action( 'save_post_appointment', ...
1
vote
1answer
34 views

Cron While Editing Post

I have a multi-author blog, on which there are two schedule cron functions. The first function moves all public posts in the pending status after 365 days: if( ! wp_next_scheduled( ...
5
votes
4answers
6k views

Force post slug to be auto generated from title on save

I'm running a property site where many properties are sold in apartment blocks. Because of this what the content editors do is create a post/property with all the details and then use a duplicate ...
1
vote
0answers
37 views

How to get updated data when save_post triggers?

I am running a function to do some stuff when save_post triggers to use new data. However, the $post object it returns, contains old data of the post, not new data! How can I get new post data inside ...
0
votes
1answer
31 views

Save post in another table

I have problem in post date, Now when i add post at 17/1/2016 and modify this post to 18/1/2016. Now the old date are delete from table in database. So, I need to save old date in another table, when ...
1
vote
0answers
33 views

Can't find infinite loop cause

I am working on the below function which will eventually create a set of posts based on meta data entered into a "parent" post. I'm running into an infinite loop when hitting the save button, which I ...
2
votes
1answer
63 views

Delete post meta conditionally after save post

I want to update/delete a post meta when a custom post (in this case custom post type is "booking") is updated upon the change of post meta . In my case if user change the post meta booking_status to ...
0
votes
1answer
17 views

Meta Box - Javascript Datatable

Hello my fellow WP Developers, I am running into a wall with a custom theme I am creating for a personal project. Background It's a website that will be used by users that collect a specific ...
1
vote
1answer
37 views

custom-meta-box checkboxes from loop won't save

I tried to create a custom meta box with checkboxes, generated from a loop of a custom-post-type. I found this example here on WP Development, but I can not figure out why the boxes won't save. My ...
0
votes
2answers
380 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 ...
8
votes
8answers
10k views

Check for update vs new post on save_post action

Is it possible within the save_post action to determine whether it's a new post being created or an existing post being update?
18
votes
1answer
9k views

Why does save_post action fire when creating a new post?

I'm surprised by the fact that my function that I've tacked onto the save_post action fires when I click the "New Post" link in the Admin Dashboard. Note - this is before I've pressed Save or Update, ...
0
votes
1answer
48 views

set_post_format called after wp_update_post when using bulk edit?

EDIT: See comments below. changing the question to reflect this new info From what I understand from the codex, save_post is meant to always fire after the post is saved (and when creating a new ...
0
votes
2answers
61 views

Allow only one post with specific meta value

I'm using a custom meta field, to specify which post will appear as a featured one in the front page. This meta field is a true/false value, declared through ACF. I want this condition to only be ...
0
votes
0answers
41 views

Metabox is not saving

Any idea, how I would get this to save? I have several select boxes that are done with the standard option statement. This one has me stumped on how to get it to save. <p> <?php $options ...
0
votes
0answers
56 views

Is it bad practice to use $_POST['post_type'] in an action hooked on save_post?

In a custom plugin I wrote an action hooked on save_post that Only needs to fire when a particular Custom Post Type is modified Sometimes uses wp_insert_post to add a post of a second Custom Post ...
0
votes
1answer
184 views

Help using acf/save_post hook to connect to Untappd API and update_field [closed]

What I am trying to accomplish is: when I save a or update a post, I want to access the Untappd API, grab a link to an image, and update an ACF field with that link. I am attempting to use the ...
0
votes
1answer
170 views

Why does post-slug not get saved for drafts?

I am trying to get the value of the 'new-post-slug' (the bit that you can edit to customize your slug for a post, but bizarrely doesn't have a 'name' attribute as you'd expect a form field to have ... ...
0
votes
2answers
1k 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 = ...
2
votes
1answer
357 views

Better post meta efficiency?

I work with websites which require using Post Meta for Post Objects within a particular Post Type. I often add a Meta Box to a particular Post Type, to provide additional settings for the new Post ...
0
votes
0answers
190 views

Trying to execute a “Save Product” command in WooCommerce through a PHP script

I've been looking for a solution for several days without success, hope you guys can help me with that. I developed a script to import Products into WooCommerce for a client which specific attributes ...
6
votes
2answers
306 views

How do the 'tag' and 'category' (default) taxonomies do 'save_post' action?

I am trying to replace the categories metabox with what looks and works like the tags metabox because there's too much hierarchy and scrolling to check the appropriate categories and sub-categories ...
0
votes
2answers
424 views

What's The Proper Way To SAnitize Checkbox Value Sent To The Database

I have tried using sanitize_text_field() and esc_attr() to filter checkbox data when saving their values to the database, but it is causing the data not being saved. What is causing it and what's the ...
0
votes
0answers
51 views

Quick Edit And Edit Actions

I'm using this code. lastpostdate is my function in project. add_action('save_post', 'lastpostdate'); It's working in mysite/wp-admin/post.php but not working in mysite/wp-admin/edit.php with quick ...
0
votes
0answers
77 views

update user data when save post

Hi I want to save authors' last post's date to wp_users table. I will use it for featured authors plugin. "date" is new column in my databese where in wp_users. function lastpostdate() { ...
0
votes
0answers
52 views

how to save custom field added to a custom taxonomy's quick edit

I registered a custom taxonomy as tags for a custom post. I use Advanced Custom Fields plugin to add a custom field to it. I wrote a plugin to customize edit-tags.php: I have my custom field showing ...
0
votes
0answers
56 views

Using function to set youtube featured image works, but doesn't update before manually clicking post update

I am using a function to set the post featured image for a youtube video (see below). My Wordpress blog post is made by IFTTT (If This Then That). The function works, but the featured image update is ...
0
votes
1answer
177 views

Update post_meta post_name with the post ID from wp_insert_post after user register

I'm creating a function that creates a page for a user when they register. The post created sits within a certain category. These are standard posts NOT custom post types. After the post is created I ...
0
votes
1answer
94 views

How can I edit comment meta value before it is saved?

I have introduced a custom field in comments form using add_comment_meta() function. I would like to know if there is a way to edit the data of the comment meta just before the post data is saved so ...