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
1answer
894 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
1answer
988 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() { ...
2
votes
2answers
1k 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 ...
1
vote
3answers
322 views

save_post action to include wp_insert_post_data filter, gathering meta field info & prevent infinite loop

Im trying to change the title of a post, but I want to include info from a meta field, the value of which isn't saved to the database until after the posts has already been saved. Other than this one ...
1
vote
4answers
659 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 row....
1
vote
2answers
554 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 ...
0
votes
1answer
1k 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
0answers
16 views

How to hook save-post function to use taxonomy term in post-slug?

Hook save-post function to check if taxonomy term is attached or not. If attached then, use taxonomy term in post slug like "taxonomy-term-other-words"...
8
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, ...
0
votes
1answer
485 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
0answers
15 views

Validate post checking if child term is assigned

For this particular case, all posts had to be a child term assigned to be published. I'm trying to hook on the "save_post" action, check the terms, return an error message if no child term is ...
2
votes
1answer
767 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. ...
0
votes
0answers
5 views

Theme only saving post fields set by the author

I have a theme I'm customizing and every time I try add my own post field (meta data) nothing gets saved yet the fields set by author do. Is there something I'm missing or are there any restrictions ...
1
vote
1answer
791 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 Edit"...
3
votes
2answers
5k views

Retrieve 1st image in post and set it as featured image, when post is saved/updated

I need to set a featured image for every post I publish. So, when a post is published/updated, the script would scan the post for the first image using a script like this: // Get URL of first ...
0
votes
0answers
8 views

Create a post on registration with title include user first name

I use this code for create a post (-type) on user registeration: function create_new_user_posts($user_id){ $userinfo = get_userdata($user_id); if (!$user_id>0) return; $my_bio_post = ...
1
vote
0answers
16 views

save imported posts as drafts

i m trying to import data into as my posts using wp all import and use add_action(save_post,myfunc) to run a function to update some fields all's good so far...but instead of publishing them all at ...
0
votes
1answer
831 views

Out of Memory - Line 791 of WP-DB.php (mysql_real_escape_string)

Update The end result is that I did not account for Apache memory limits. There were limits placed on the Apache process which caused PHP to be limited regardless of the settings placed on it. ...
3
votes
2answers
40 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
31 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
0answers
22 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?
0
votes
1answer
28 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
47 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 ...
3
votes
0answers
73 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
25 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
75 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
31 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
96 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
80 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
25 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
37 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
47 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
33 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
36 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
82 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
18 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
48 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
398 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
11k 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?
20
votes
1answer
10k 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
55 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 post)...
0
votes
2answers
71 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
42 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
76 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
221 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 acf/...
0
votes
1answer
189 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
375 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 ...