I am trying to use this https://gist.github.com/davejamesmiller/1966425 to fire when I first create WordPress site / "install WordPress" (i.e complete the "5 minute setup") but the wpmu_new_blog action does not seem to get fired.

Is there an action I can hook to catch the initial site creation / WordPress Installation?

I would like to start my new site with a set up plugins activated.

Initial setup:


The main component you are probably missing is dropping your customizations in an install.php file in the wp-content directory.

If you look at the /wp-admin/includes/upgrade.php you will be able to see exactly how it is included and the installation functions you can override. I am not sure if that will be good enough to catch the hook you want to use but you will probably be able to find another hook on which to "hang" your DB modifications.

  • I vote for Mark's answer :) Completely forgot about that file! – s_ha_dum Apr 10 '15 at 14:10

WordPress' installation file defines a constant called WP_INSTALLING

27    /**
28     * We are installing WordPress.
29     *
30     * @since 1.5.1
31     * @var bool
32     */
33    define( 'WP_INSTALLING', true );


Given that, I think you could hook to an action like wp_loaded and check for that constant, running your installation code if it is set and true.

function run_on_install_wpse_183768() {
  if (defined(WP_INSTALLING) && true == WP_INSTALLING) {
    // your code

This is untested and, as I am sure you can imagine, time consuming to test but I think it would work.

  • 1) Should be defined('WP_INSTALLING'). 2) Isn't that too early though to activate a plugin? I am getting the following WordPress database error Table 'wordpress.wp_options' doesn't exist for query INSERT INTO 'wp_options' ....., do_action('wp_loaded'), call_user_func_array, run_on_install_wpse_183768, djm_activate_plugin, do_action('....'), call_user_func_array, WP_Auth0::install, WP_Auth0::install_db, update_option, add_option – Alex Rothberg Apr 10 '15 at 2:26

This seems to work:

function agr_wp_install($user){
add_action('wp_install', 'agr_wp_install', 1);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.