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

1
vote
0answers
13 views

Upload File Metabox - Empty Files on POST

I'm creating a simple / generic upload file metabox. For some reason when I upload a file and update my post, it doesn't pull my uploaded file along with it, the $_FILES array will be completely ...
0
votes
0answers
24 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
28 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
27 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
48 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
23 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
9 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
58 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
57 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
62 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
21 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
78 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
58 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
28 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
16 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
60 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 ...
0
votes
1answer
377 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
173 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
0answers
27 views

How can I check if taxs changed on save_post/post_updated action?

Im running some custom actions on the 'post_updated' action hook. But I need to know if the taxonomies changed on post update to run some extra functions. The action hook only returns $post_after and ...
0
votes
1answer
106 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
139 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
42 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
55 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
104 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
12 views

Post array not printing after post is published? [duplicate]

I'm using this function which displays the post array when I click Add new post. After the post has been published I do not see the array of the published post. What's wrong with the code? I've also ...
0
votes
0answers
54 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
348 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
179 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
47 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
94 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
0answers
77 views

Prevent save_post from running when preview button pressed?

I have a bug where my content gets saved twice (2 seperate rows in the posts table). This post creation is for a custom post type so the bug is to do with my code. To reproduce I: Create a new ...
0
votes
2answers
31 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 ...
1
vote
1answer
324 views

“save_post” hook not triggered in WP 3.6.1

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

How to stop a user from updating the post date

I have a custom role, called "dealer". Once they have posted a new post, they cannot delete it. It's important they cannot update the date either, and I'm a little stuck on how to do this. It looks ...
0
votes
1answer
53 views

Update Post Taxonomy Automatically Based On Date

I am using the below function to set a custom post type taxonomy to a certain term based on the current date. This is for an event that lists upcoming, ongoing, and future events at a venue. I need ...
1
vote
0answers
158 views

How to notify specific users when i'm posting/modifying a new post

Here's what I'm trying to do... I'm trying to send new submissions only to contractors requested. Using Role Scoper, I can select only users who can access the new submission. However, I am looking ...
1
vote
1answer
71 views

Change 2 fields in the post depending on the 3rd field before save

I have a custom content type called cards. I have 3 custom meta fields called: my_cards_activity (select field type; options 0 and 1) my_cards_user (select type; many options) my_cards_datetime ...
0
votes
1answer
97 views

Front end update_post_meta Help

I followed the help provided in this question but cannot get the form save the data. I tried using 'save_post' action hook to try and save the post like we do for admin side. Any help would be highly ...
0
votes
1answer
22 views

How to prevent meta data from being edited in a post?

I need to add a 'poll' to every single post automatically, and wish to do this without having to manually create a poll each time using a plugin, so I had an idea to store the poll results as meta ...
0
votes
1answer
57 views

How to save post change url youtube link?

In functions.php i using this to change width url from youtube: add_action('save_post', 'set_url_youtube'); function set_url_youtube() { $post = get_post($post_id); $content = ...
1
vote
0answers
87 views

Saving Custom Field Data before Publish

When creating a page or a post WordPress lets the content (title, body, featured image) be saved when using Ctrl + S. The Custom Fields do not save in the same way (in this case I'm using Advanced ...
0
votes
1answer
136 views

How do I save each option in a multiple select menu as it's own meta_key + meta_value pair?

How do I save each option in a multiple select menu as it's own meta_key + meta_value pair? This is the basic multiple select menu. Note: multiple select menus allow you to select more than one ...
0
votes
2answers
131 views

Custom metabox not displaying multiselect data in edit mode

I have a custom metabox in a custom post type that records system outages across the campus that I work at. One of the fields in the metabox is a multiselect box listing all the buildings on campus. ...
0
votes
1answer
97 views

How to validate select field in post meta?

I want to display a select dropdown field in the post meta. How can I validate the input before saving it? Currently, I am simply saving without validating like this: if ( isset( ...
0
votes
1answer
169 views

Update Custom Field on Imported Post Creation

So I've created a function that updates several custom fields in a post when the post is created. The idea is to sanitize this information so that I can easily use it for other purposes. The ...
0
votes
1answer
448 views

Custom wp_editor doesn't update post_content

I'm working on a client's site, creating a staff profile plugin. The issue is that they previously created the profiles as regular posts. I converted all of the staff posts into a custom post types. ...
0
votes
2answers
106 views

save post running twice and creating two database entries - how do I disable this?

I am developing a job tracking database for my utility engineering company and am having an issue when running a save hook. I have a task_types db table that tasks are created off of and using a ...
0
votes
2answers
37 views

Prevent Page/Post From Being Created based on Pages/Posts per User per Time Unit

I'm working on new project and I want to let users have access to create pages on the site. To prevent users from "spamming" a lot of pages, I'd like to set a daily upload limit for each user. I've ...
0
votes
1answer
55 views

where does this $post_id come from?

I was trying to figure out why save_post wasn't being fired upon 'Quick edit', and found the solution here - apparently global $post is not available when updating a post in Quick edit mode. So - I ...
1
vote
2answers
96 views

How to run a function once on every post in database?

I have a simple function that automatically formats the whole post after publishing/updating. It's hooked on: add_action('save_post', 'myFunction'); I would like to format every post, that I ...