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
1answer
1k views

Save selected item from dropdown menu in a meta box as a metadata value for a custom post type

I have been beating my brains on this one for days now and my Google-fu is failing me. I have created a custom meta box with a dropdown menu that lists all of the terms from a custom taxonomy. What I ...
1
vote
1answer
1k views

How can i create a function to get youtube video time

Tom J Nowell posted this code to help me retrieve the YouTube video time. Functions // function to parse the code from the URL function parse_youtube_video_id_from_url( $video_url ) { ...
1
vote
3answers
2k views

Custom post type save_post action not firing

Sorry if this is already answered on here. I looked around and couldn't see any answers to my question so I thought I'd post my own. I'm building a plugin for a client that gathers customer feedback ...
1
vote
1answer
585 views

How to create a front facing user sign up, log in and profile pages like FoodGawker.Com

Title: How to create a front facing user sign up, log in and profile pages like FoodGawker.Com Body: Hey everyone! I'll be as direct and detailed as possible. :) I want to be able to sign up ...
1
vote
1answer
79 views

Publish/Update post is changing image links from file url to post url

I've written a filter to wrap images included in posts with figure tags and their captions with figcaption tags. I turned off the visual editor so that it doesn't strip out all the html from the ...
1
vote
1answer
552 views

How can I set taxonomy programmatically

Here is my situation. I plan to distribute a theme I am working on and it has a custom post type called Code and it has a custom taxonomy called Languages now I also use a custom metabox with a ...
1
vote
1answer
177 views

save_post requiere at least one uploaded file to be published

Is there a way to check the Published status of a post, and if it doesnt has at least one image or file uploaded, then change status of published to draft? Thanks in advance.
1
vote
1answer
454 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
74 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 ...
1
vote
1answer
492 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
0answers
203 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
110 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 ...
1
vote
1answer
302 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
259 views

get_terms on save_post hook

Usually, if I want to check for some attribute of the post I'm about to publish, I will check like this: $post_title = $_POST['post_title']; post_title is the name of the title field in the edit ...
1
vote
4answers
413 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 ...
1
vote
0answers
94 views

Events: Check for other event with same start date and category

I am using The Events Calendar and (correct me if I'm wrong) there is no checking to see if an event has a time conflict with another event that's already been entered. For example, if there is ...
1
vote
1answer
475 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 ...
1
vote
0answers
152 views

Save modified Custom Field content into another Custom Field on article save [closed]

In my articles I allow editors to enter a date in a human readable dd.mm.yyyy format into a custom field. But I also need this date as unix timestamp in the DB. So I wrote a function which takes the ...
0
votes
2answers
886 views

Remove image from post_content on save_post

I'm trying to setup a function in functions.php that removes an image from the post_content on save. Everything works up until the time I'm trying to save the content, the page just hangs and I get a ...
0
votes
1answer
197 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
146 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
1answer
310 views

Compare custom taxonomies of updated post (or new post) [Updated with progress]

I am using the Transients API to cache category loops for a custom taxonomy. All works fine, but if I add a new post or update an existing one, I woud like to compare the taxonomy values and then ...
0
votes
1answer
243 views

save_post action doesn't passing post id to my function as argument

I'm adding a box to add / update post screen. add_action( 'save_post', 'psd_upload_kaydet' ); add_action( 'add_meta_boxes', 'psd_upload' ); function psd_upload() { add_meta_box("psd-upload", "Bir ...
0
votes
2answers
74 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
23 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
188 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
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 ...
0
votes
2answers
676 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
196 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 ...
0
votes
1answer
963 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. ...
0
votes
1answer
117 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
62 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 ...
0
votes
1answer
102 views

displaying an error before update_post_meta

I'm trying to restrict how many items you can associate with a post so in my save function I have: add_action( 'save_post', array( $this, 'save_custom_items_data' ), 10, 2 ); public function ...
0
votes
1answer
143 views

Minimum Word Count Before A Post Can Be Made Pending Review

I'm looking for a way to check that a post has a minimum word count before allowing it to be sent for review (added to the pending post status). Below is the code I have: if ...
0
votes
1answer
926 views

Is there an easy way to AJAX-ify saving of post?

We have a plugin that allows us to manage custom post types and we'd like to add AJAX functionality in saving, editing, and deleting posts. I couldn't find similar problems in the internet so I'm ...
0
votes
2answers
582 views

Save post meta foreach loop

My brain has fallen over. How do I save this post data? Building some key-value pairs in the form. for ($i = 1; $i <= 3; $i++) { $saved = $meta[$i]; //print_r($saved); ...
0
votes
1answer
884 views

Migrating from metaboxes to wp_editor()

I got a client requirement where the editing facilities available in wordpress had to be available for content that was meant to be displayed on the sidebar of a particular post/page. The content to ...
0
votes
1answer
328 views

Custom field values get deleted

I created a custom post type:products which also has custom fields: price & shipping. Occasionally, if I leave the edit product window open or refresh it, I lose the values inside price and ...
0
votes
1answer
114 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
44 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
256 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
76 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 ...
0
votes
2answers
35 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 ...
0
votes
1answer
63 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 ...
0
votes
1answer
122 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
25 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
215 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
209 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
601 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
69 views

Save custom value to main content of post

I create a meta custom input to make a page builder. So i can drop & drag element to build content for post. And when i save post, i want it will save directly to post content. So i think i will ...