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
0answers
58 views

update_post_meta not working in save_post hook

I have this hook: function save_custom_meta_data($post_id, $post, $is_update){ // avoid infinite loop remove_action('save_post_myposttype', 'save_custom_meta_data', 10, 3); $custom_meta_data = ...
1
vote
0answers
16 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
2answers
38 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 ...
0
votes
1answer
20 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
24 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 ...
1
vote
1answer
31 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
13 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
14 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
50 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
1answer
27 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
0answers
39 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
29 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
59 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
0answers
76 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 ...
0
votes
0answers
42 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
2answers
203 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 ...
6
votes
2answers
271 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
0answers
63 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
39 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
33 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
94 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
60 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 ...
0
votes
1answer
34 views

WordPress save_post hook not firing when checking if _GET['post'] is set

I was facing an issue (a custom metabox not saving), and after 2 hours I finally realised that, if you try to add an action to the save_post hook inside an if statement checking whether $_GET['post'] ...
1
vote
2answers
125 views

Returning ACF custom field from publish_post

I'm trying to return a custom field as soon as a post gets published. I'm using the publish_post (or {status}_{post_type}) action, but it looks like the custom fields are created after the hook. My ...
0
votes
0answers
123 views

Page content not saving, can not save page content

I'm trying to figure out what's wrong with the page editor at my wordpress installation. When I create a new page and insert title and content, the title is being saved but the content field turns ...
0
votes
0answers
119 views

create a form and save data into new table

I want to create new form to add my customer details including name, email, contact num, address Once created, this form should store all these values into newly created table and also generate 4 ...
0
votes
1answer
40 views

Custom metabox does not store data

I'm troubled with a custom metabox, could someone give me a helping hand? I've got a custom post type which uses it, but unfortunately it's not storing the data into the database. Any clue? ...
1
vote
0answers
30 views

How to change the attached image's name after save post? [closed]

I would like to let the user upload images with any name, and automatically modify their name to the format as %post_id%-01, %post_id%-02, %post_id%-03... when save post. And I'm using the plugin ...
0
votes
1answer
21 views

Why WordPress takes time to make request to save post?

I have around 50 post meta fields, each meta field have different values. I have noticed when saving posts, it takes around 3 to 4 seconds to make request. Why?
1
vote
0answers
64 views

publish_post conflicts with save_post

my plugin has a save_post hook used to save the custom fields. now I add a publish_slider hook used to change a checkbox's status(slider is a custom post type). but it doesn't work properly. the ...
0
votes
0answers
180 views

How to manage saving custom field from Quick edit and Post Save using save_post action hook without colliding each other?

I's following Rachel Carden's tutorial on creating Quick Edit and Bulk Edit, and grabbed her full work from her github repo. I managed doing everything fine and I made a checkbox instead of radio ...
0
votes
0answers
117 views

Check if value has changed on save_post

Writing a function to send an email to the user on save_post if a taxonomy equals a specific value. However, I only want this to happen when the value is being changed, and not on every save. Is there ...
1
vote
0answers
20 views

CPT Validation to not show “Post updated.”

Now this has been asked several times over on all WP forums, but how you change the success message? First, I know there are 2 choices for managing the error message: setting in the options and using ...
1
vote
0answers
143 views

Update post meta using save_post hook in multisite

I am trying to update a post meta field in a custom post type in Multisite. i am using the save_post hook to do so unsuccessfully. I don't know if the reason / cause is the multisite? or wrong use of ...
1
vote
2answers
250 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
189 views

duplicate entries in database while using save_post or wp_insert_post

Here is what I am trying to do - I have created a custom table in the database and I am trying to enter data into it everytime a post is created. The database-entry needs to happen ONCE AND ONLY WHEN ...
0
votes
0answers
49 views

Woocommerce conflict with new “submit_button”

I have replace the submitdiv meta box (publish box) with just one simple save button. All working fine with post/page and custom post type (plugins that i have install that create custom post type). ...
0
votes
1answer
58 views

WP_Query within save_post doesn't include the item that triggered the action?

I'm using Advanced Custom Field's acf_form function to expose a front-end form for users to post content on the website. Users will be submitting photos of redfish they have caught, and one of the ...
0
votes
1answer
43 views

Conditional for autosave or auto draft?

I am attempting to create a file using fopen() on save_post. I am having trouble finding the right condtionals to prevent the the file from being created from an auto save. I only want to create the ...
0
votes
0answers
30 views

How to add a div area inside post edit page after Publishing or updating a post or page

I am trying to create a div area when i update or publish a post function my_save_post_function($post_id) { echo "<div class="default">Hello</div>"; return $post_id; ...
0
votes
2answers
116 views

Connection Reset on post/page save

I'm working on a client's fresh install and server. Every time I attempt to save a post or page, I'm immediately sent a connection reset error (This webpage is not available - ERR_CONNECTION_RESET). ...
0
votes
1answer
49 views

Generate slug and meta data if meta field is empty

I am creating a current vacancies feature in a client site, and am struggling on one area. I want to have a slug generated from a reference number, rather than the post title. This, I have set up. ...
0
votes
1answer
148 views

Post meta checkbox becomes unchecked occasionally

I removed the default author meta box on posts and added it back with a checkbox that I use to determine if a post should show the author's byline and author box. It's been working, but for some ...
0
votes
1answer
62 views

Cant't delete my custom posts

I added this code in function.php in order to replace post_date with an ACF field every time i update mu custom post. It works perfectly ! BUT Now in WP admin i can't delete (to trash) any custom ...
0
votes
0answers
30 views

Replacing Standard Category Metabox

I am rewriting the standard category metabox to include a Custom Field as a select box which is dynamically updated as the user chooses the categories. This select box is set with all "checked" ...
1
vote
2answers
240 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 ...
0
votes
0answers
35 views

Detect current user during save_post or post_updated

I have a function, hooked to the save_post ( post_updated ) action. I want to detect who is the user saving ( updating ) the post?! function my_fun(){ global $user_ID; $user_info = get_userdata( ...
0
votes
1answer
128 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
1answer
198 views

Checked() function on a multidimensional array

I am generating checkboxes dynamically on one of the option pages. This the code that I'm using to create multiple checkboxes: <?php foreach($shopCategories as $shopCategory) { ?> <input ...
0
votes
1answer
77 views

flush_rewrite_rules on save_post does not work on first post save

I am developing a plugin for my own rapid development that creates a custom post type. The 'list' for this post type is displayed on a specific page that is created and managed by the plugin. This ...