Title: run function after wordpress native save
Last modified: August 21, 2016

---

# run function after wordpress native save

 *  Resolved [bjusters](https://wordpress.org/support/users/bjusters/)
 * (@bjusters)
 * [12 years ago](https://wordpress.org/support/topic/run-function-after-wordpress-native-save/)
 * I would like to be able to run a function after the WordPress native save of 
   a post is done, so the data is already in the db. I`d like to write data from
   an acf repeater field to a more flat tablet, so searching this data will be a
   lot faster.
 * I searched through the forum and looked at the save_post hook, but it didn`t 
   get clear to me how i can do the trick.
 * Foed anyone have an idea on how to do make it work?

Viewing 6 replies - 1 through 6 (of 6 total)

 *  [catacaustic](https://wordpress.org/support/users/catacaustic/)
 * (@catacaustic)
 * [12 years ago](https://wordpress.org/support/topic/run-function-after-wordpress-native-save/#post-4941755)
 * As an example:
 *     ```
       function myplugin_save_post () {
           global $post;
   
       	if ((!defined ("DOING_AUTOSAVE") || !DOING_AUTOSAVE) && get_post_type ($post) == "my_post_type") { // Post type can also be page, post, etc
       		update_post_meta ($post->ID, "meta_key", $_POST ["meta_value"]);
       	} // if ()
       }
   
       add_action ("save_post", "myplugin_save_post");
       ```
   
 * That’s all there is to it. You just need to add whatever code in there to process
   and save the data the way that you want it.
 *  Thread Starter [bjusters](https://wordpress.org/support/users/bjusters/)
 * (@bjusters)
 * [12 years ago](https://wordpress.org/support/topic/run-function-after-wordpress-native-save/#post-4941774)
 * Thank you very much,
 * however this is still triggering it before the native WordPress save right?
 * i`ve "build" an ACF repeater field with 1 date field and four checkboxes, people
   fill in about 100 rows, that`s why i wanted wordpress to do it`s thing first,
   and after that i can just use the ACF repeater field to put it in an easy usable
   array (instead of the ACF backend $_POST array)
 * the idea that got to me just now, is figuring out how i can prioritize my save_post
   hook in that way, that it`s get`s executed after the ACF save is done, in that
   way i can use it in my preferred way.
 * thanks for the solution and the insight!
 *  [catacaustic](https://wordpress.org/support/users/catacaustic/)
 * (@catacaustic)
 * [12 years ago](https://wordpress.org/support/topic/run-function-after-wordpress-native-save/#post-4941784)
 * No. It triggers after the post/page/etc is saved. Not before. WordPress does 
   it’s stuff, and then performs this trigger.
 * If you’re at all concerned you can look at the third parameter for the ‘add_action()’
   function which is the priority. Set that higher and it will be processed last.
 *  Thread Starter [bjusters](https://wordpress.org/support/users/bjusters/)
 * (@bjusters)
 * [12 years ago](https://wordpress.org/support/topic/run-function-after-wordpress-native-save/#post-4941796)
 * Grazie,
 * i fiddled around with it like a year ago or something to move data to xml, to
   relieve the database, and i got the idea is was triggered lateron.
 * I can see in the ACF code (that uses add_action save_post as well, didn`t think
   of that before either) this rule:
 *     ```
       add_action('acf/save_post', array($this, 'save_post_lock'), 0);
       add_action('acf/save_post', array($this, 'save_post'),10);
       add_action('acf/save_post', array($this, 'save_post_unlock'), 999);
       ```
   
 * so i`ll just hook in at at least 1000 and i`ll be fine. Thanks for your wisdom,
   really appreciate it!
 *  [catacaustic](https://wordpress.org/support/users/catacaustic/)
 * (@catacaustic)
 * [12 years ago](https://wordpress.org/support/topic/run-function-after-wordpress-native-save/#post-4941797)
 * To be honest. I have got no idea what the “acf” code is. That seems like it’s
   some external library to the standard WordPress actions.
 * And.. yes it is.
 * If you need help with that plugin I’d suggest that you ask in the plugins support
   forum. [http://wordpress.org/support/plugin/advanced-custom-fields](http://wordpress.org/support/plugin/advanced-custom-fields)
 *  Thread Starter [bjusters](https://wordpress.org/support/users/bjusters/)
 * (@bjusters)
 * [12 years ago](https://wordpress.org/support/topic/run-function-after-wordpress-native-save/#post-4941798)
 * The plugin wasn`t the problem, i was my lack of understanding of the hooks itself
   of which the plugin makes use as well.
 * For all the future readers of this post:
 * ACF stands for Advanced Custom Fields and has become an essential plugin for 
   me in WordPress. (therefor ACF has become a normal verb in my dictionary:)

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘run function after wordpress native save’ is closed to new replies.

## Tags

 * [after](https://wordpress.org/support/topic-tag/after/)
 * [save_post](https://wordpress.org/support/topic-tag/save_post/)

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 6 replies
 * 2 participants
 * Last reply from: [bjusters](https://wordpress.org/support/users/bjusters/)
 * Last activity: [12 years ago](https://wordpress.org/support/topic/run-function-after-wordpress-native-save/#post-4941798)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
