New Blog Template Hook to run after set_blog_defaults

Hello @Jose,

I was wondering if there was a hook that ran after the New Blog Templates' function "set_blog_defaults". As you know I've recently set up some additional copy options HERE.

I need to now write code to copy my new options, but, would like to run that code after New Blog Templates does its thing. Is there a hook I can use to do this or would I follow New Blog Templates approach and set my copy function to be the very last action to run after "wpmu_new_blog" hook? I don't quite understand how you did it using the

            add_action('wpmu_new_blog', array($this, 'set_blog_defaults'), apply_filters('blog_templates-actions-action_order', $action_order), 6); // Set to *very high* so this runs after every other action; also, accepts 6 params so we can get to meta

thank you,


  • Predrag Dubajic

    Hey @hoangker,

    Hope you're doing well today :slight_smile:

    I must say this is a bit beyond my knowledge of coding so I'm going to flag to to our second level support developers to have a look at.
    Please note that, developer response might be slower than usual staff response, so we appreciate your patience on this.

    Also, if you need to customize this then you can post a job in our job board where you can hire a developer to assist further:
    Please note that, no WPMU official staff members are allowed to work in the job board.

    Best regards,

  • Jose

    Hi there hoangker,

    Is there a hook I can use to do this or would I follow New Blog Templates approach and set my copy function to be the very last action to run after "wpmu_new_blog" hook?

    No, there is no specific hook for this. You should follow NBT approach.

    Let me explain the following code:

    By default, NBT will hook into "wpmu_new_blog" with a priority of 9999.
    But first, it will check -by using a ternary operator- if the constant NBT_APPLY_TEMPLATE_ACTION_ORDER is defined to a different value. In case it is defined, it will use that value. This might be handy when you need to change the priority for any reason, so you can simply add the following in your wp-config.php or somewhere in your code:
    define('NBT_APPLY_TEMPLATE_ACTION_ORDER', 20); //This will change the priority to 20.

    Also, there is another constant used in NBT that might cause some issues: NBT_ENSURE_LAST_PLACE.
    By default, it is not defined so you shouldn't have issue. But, if it is defined, it will always set the priority to the higher priority + 10. So, if you set your hook to a priority of 10000, it will override the hook and move it to a priority of 10010.

    If you won't be using the NBT_ENSURE_LAST_PLACE option, then you can simply use this:
    add_action('wpmu_new_blog', 'your_function_here', 10000, 6); // Set to 9999 + 1

    If you think that NBT_ENSURE_LAST_PLACE option might be defined in your environment, then you should use a more aggressive approach:

    function add_hook_on_last_place(){
       add_action('wpmu_new_blog', 'your_function_here', PHP_INT_MAX, 6);//Will set the priority to the higher integer value allowed.
    add_action('init', 'add_hook_on_last_place', 999);//Run after NBT moved to the higher priority.

    Hope this is clear enough.
    Please don't hesitate to ask if you have any question.


Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.