Title: Init hook priority issue
Last modified: March 16, 2018

---

# Init hook priority issue

 *  Resolved [ewinter](https://wordpress.org/support/users/ericwinter/)
 * (@ericwinter)
 * [8 years, 2 months ago](https://wordpress.org/support/topic/init-hook-priority-issue/)
 * On my site I have a lot of custom post types configured using PODS plugin. When
   submitting front end forms these post types aren’t registered yet.
    To fix the
   problem I had to change the ‘init’ hook priority in core/core-forms.php:15 from
   10 to wordpress default 15. `add_action( 'init', array( $this, 'pre_form' ), 
   15, 0 );`
 * After some testing, it seems that everything is working fine – can you please
   include this fix in the next release?
 * Thanks in advance,
    Eric

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

 *  Thread Starter [ewinter](https://wordpress.org/support/users/ericwinter/)
 * (@ericwinter)
 * [8 years, 2 months ago](https://wordpress.org/support/topic/init-hook-priority-issue/#post-10090256)
 * Update: Changing the priority only in core-forms introduces errors with form 
   emails. Therefor all other wordpress related hooks must be changed to the same
   value too.
 * I now investigated other plugins that may be used together with Advanced Forms
   like: PODS, CPTUI, other ACF-Extensions, Shortcode related plugins like WPBakery
   Pagebuilder + Addons, and email related plugins like WPSMTP and I would propose
   changing the hook priority to 14 for all directly worpress core related hooks
   like ‘init’, ‘admin_init’, ‘edit_form_after_title’, ‘save_post’, ‘media_buttons’,‘
   admin_notices’, …
    This would allow other plugins to run its hooks before Advanced
   Forms and user hooks (priority >= 15) after.
 * Would you please include this change or at least
    a) a workarround like user 
   changable priorities or b) a function or hook to get the reference to you class
   instances allowing to unset and reregister your hooks.
 * Greets, Eric
 *  Plugin Author [fabianlindfors](https://wordpress.org/support/users/fabianlindfors/)
 * (@fabianlindfors)
 * [8 years, 2 months ago](https://wordpress.org/support/topic/init-hook-priority-issue/#post-10105572)
 * Hi!
 * I’m not quite sure I follow. I think I currently use priority 10 in most places
   because that is the WordPress default ([documentation](https://developer.wordpress.org/reference/functions/add_action/))
   and I thought that would be the safest choice.
 * I haven’t tried any of the plugins you named with AF. Do these plugins all register
   their post types at a priority of 10 or higher?
 * Hope we can come to a solution here!
 *  Thread Starter [ewinter](https://wordpress.org/support/users/ericwinter/)
 * (@ericwinter)
 * [8 years, 2 months ago](https://wordpress.org/support/topic/init-hook-priority-issue/#post-10105647)
 * Hi!
 * Thanks for your reply and sorry for my fault – I was completely certain, that
   the default is 15 🙂
    PODS and all other named plugins are mostly using the default
   priority. Because wordpress loads plugins in alphabetical order yours is loaded
   first and therefore your hooks are registered before others with the same priority.
   In my usecase I want to create a post of a custom post type using the submitted
   form data, therefore PODS have to be loaded before Advanced Forms. I don’t know
   if you want your custom post types form and entry to get extended by user. In
   this case the current load order is fine. But I think both should be possible.
   The main problem is, that you are using the ‘init’ hook to process submitted 
   forms. What do you think about using ‘wp_loaded’ to call pre_form function? Another
   option would be to submit your forms using ajax and making use of the default
   ajax actions. But I think this is too much work for a small problem.
 * Best regards,
    Eric
 *  Plugin Author [fabianlindfors](https://wordpress.org/support/users/fabianlindfors/)
 * (@fabianlindfors)
 * [8 years, 2 months ago](https://wordpress.org/support/topic/init-hook-priority-issue/#post-10121469)
 * Oh I see! It’s very unfortunate that those plugin use the default priority, ACF
   for example uses a lower one for it’s initialization.
 * I think I should probably raise the priority of the pre_form function to battle
   this problem. I will try it out and hopefully include it in the next release.
 * Thank you for pointing this out!

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

The topic ‘Init hook priority issue’ is closed to new replies.

 * ![](https://ps.w.org/advanced-forms/assets/icon-256x256.png?rev=1894254)
 * [Advanced Forms for ACF](https://wordpress.org/plugins/advanced-forms/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/advanced-forms/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/advanced-forms/)
 * [Active Topics](https://wordpress.org/support/plugin/advanced-forms/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/advanced-forms/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/advanced-forms/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [fabianlindfors](https://wordpress.org/support/users/fabianlindfors/)
 * Last activity: [8 years, 2 months ago](https://wordpress.org/support/topic/init-hook-priority-issue/#post-10121469)
 * Status: resolved