0

I created a plugin that makes use of the wp_install method (this part is necessary for the plugin to work properly and this function needs to be called).

http://wpseek.com/function/wp_install/

Within it, the wp_new_blog_notification method is called to fire off the standard WordPress email right after installation (this part is not necessary for the plugin).

http://wpseek.com/function/wp_new_blog_notification/

Does anyone know if there's a way to hook into the method and stop the email from being fired?

EDIT:

I should also mention that within the plugin, I created a filter:

add_filter( 'wp_mail', array( $this, '_fix_mail' ) );

where the _fix_mail method simply looks for the strings within the wp_new_blog_notification and replaces them with custom ones. However, this is strictly because I can't seem to stop it from firing. A better solution would be to just not send the installation email.

0

1 Answer 1

0

If you see the code, there is no hook to do that. But you can create your own function and remove the part that you don't need like this

function custom_wp_install( $blog_title, $user_name, $user_email, $public, $deprecated = '', $user_password = '', $language = '' ) {
    if ( !empty( $deprecated ) )
        _deprecated_argument( __FUNCTION__, '2.6' );

    wp_check_mysql_version();
    wp_cache_flush();
    make_db_current_silent();
    populate_options();
    populate_roles();

    update_option('blogname', $blog_title);
    update_option('admin_email', $user_email);
    update_option('blog_public', $public);

    if ( $language ) {
        update_option( 'WPLANG', $language );
    }

    $guessurl = wp_guess_url();

    update_option('siteurl', $guessurl);

    // If not a public blog, don't ping.
    if ( ! $public )
        update_option('default_pingback_flag', 0);

    /*
     * Create default user. If the user already exists, the user tables are
     * being shared among blogs. Just set the role in that case.
     */
    $user_id = username_exists($user_name);
    $user_password = trim($user_password);
    $email_password = false;
    if ( !$user_id && empty($user_password) ) {
        $user_password = wp_generate_password( 12, false );
        $message = __('<strong><em>Note that password</em></strong> carefully! It is a <em>random</em> password that was generated just for you.');
        $user_id = wp_create_user($user_name, $user_password, $user_email);
        update_user_option($user_id, 'default_password_nag', true, true);
        $email_password = true;
    } elseif ( ! $user_id ) {
        // Password has been provided
        $message = '<em>'.__('Your chosen password.').'</em>';
        $user_id = wp_create_user($user_name, $user_password, $user_email);
    } else {
        $message = __('User already exists. Password inherited.');
    }

    $user = new WP_User($user_id);
    $user->set_role('administrator');

    wp_install_defaults($user_id);

    wp_install_maybe_enable_pretty_permalinks();

    flush_rewrite_rules();

    wp_cache_flush();

    /**
     * Fires after a site is fully installed.
     *
     * @since 3.9.0
     *
     * @param WP_User $user The site owner.
     */
    do_action( 'wp_install', $user );

    return array('url' => $guessurl, 'user_id' => $user_id, 'password' => $user_password, 'password_message' => $message);
}
1
  • I was trying to avoid having to copy and paste the entire function and delete one line. I guess that might be the only way. Jun 12, 2015 at 19:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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