Title: wp_install
Published: April 25, 2014
Last modified: February 24, 2026

---

# wp_install( string $blog_title, string $user_name, string $user_email, bool $is_public, string $deprecated, string $user_password, string $language ): array

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/wp_install/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/functions/wp_install/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/wp_install/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/wp_install/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/functions/wp_install/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/functions/wp_install/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_install/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/wp_install/?output_format=md#wp--skip-link--target)

Installs the site.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/wp_install/?output_format=md#description)󠁿

Runs the required functions to set up and populate the database, including primary
admin user and initial options.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/wp_install/?output_format=md#parameters)󠁿

 `$blog_title`stringrequired

Site title.

`$user_name`stringrequired

User’s username.

`$user_email`stringrequired

User’s email.

`$is_public`boolrequired

Whether the site is public.

`$deprecated`stringoptional

Not used.

`$user_password`stringoptional

User’s chosen password. Default empty (random password).

`$language`stringoptional

Language chosen. Default empty.

## 󠀁[Return](https://developer.wordpress.org/reference/functions/wp_install/?output_format=md#return)󠁿

 array Data for the newly installed site.

 * `url` string
 * The URL of the site.
 * `user_id` int
 * The ID of the site owner.
 * `password` string
 * The password of the site owner, if their user account didn’t already exist.
 * `password_message` string
 * The explanatory message regarding the password.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/wp_install/?output_format=md#source)󠁿

    ```php
    function wp_install(
    	$blog_title,
    	$user_name,
    	$user_email,
    	$is_public,
    	$deprecated = '',
    	#[\SensitiveParameter]
    	$user_password = '',
    	$language = ''
    ) {
    	if ( ! empty( $deprecated ) ) {
    		_deprecated_argument( __FUNCTION__, '2.6.0' );
    	}

    	wp_check_mysql_version();
    	wp_cache_flush();
    	make_db_current_silent();

    	/*
    	 * Ensure update checks are delayed after installation.
    	 *
    	 * This prevents users being presented with a maintenance mode screen
    	 * immediately after installation.
    	 */
    	wp_unschedule_hook( 'wp_version_check' );
    	wp_unschedule_hook( 'wp_update_plugins' );
    	wp_unschedule_hook( 'wp_update_themes' );

    	wp_schedule_event( time() + HOUR_IN_SECONDS, 'twicedaily', 'wp_version_check' );
    	wp_schedule_event( time() + ( 1.5 * HOUR_IN_SECONDS ), 'twicedaily', 'wp_update_plugins' );
    	wp_schedule_event( time() + ( 2 * HOUR_IN_SECONDS ), 'twicedaily', 'wp_update_themes' );

    	populate_options();
    	populate_roles();

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

    	// Freshness of site - in the future, this could get more specific about actions taken, perhaps.
    	update_option( 'fresh_site', 1, false );

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

    	$guessurl = wp_guess_url();

    	update_option( 'siteurl', $guessurl );

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

    	/*
    	 * Create default user. If the user already exists, the user tables are
    	 * being shared among sites. Just set the role in that case.
    	 */
    	$user_id        = username_exists( $user_name );
    	$user_password  = trim( $user_password );
    	$email_password = false;
    	$user_created   = 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_meta( $user_id, 'default_password_nag', true );
    		$email_password = true;
    		$user_created   = 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 );
    		$user_created = true;
    	} else {
    		$message = __( 'User already exists. Password inherited.' );
    	}

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

    	if ( $user_created ) {
    		$user->user_url = $guessurl;
    		wp_update_user( $user );
    	}

    	wp_install_defaults( $user_id );

    	wp_install_maybe_enable_pretty_permalinks();

    	flush_rewrite_rules();

    	wp_new_blog_notification( $blog_title, $guessurl, $user_id, ( $email_password ? $user_password : __( 'The password you chose during installation.' ) ) );

    	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,
    	);
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-admin/includes/upgrade.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-admin/includes/upgrade.php#L47)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-admin/includes/upgrade.php#L47-L160)

## 󠀁[Hooks](https://developer.wordpress.org/reference/functions/wp_install/?output_format=md#hooks)󠁿

 [do_action( ‘wp_install’, WP_User $user )](https://developer.wordpress.org/reference/hooks/wp_install/)

Fires after a site is fully installed.

## 󠀁[Related](https://developer.wordpress.org/reference/functions/wp_install/?output_format=md#related)󠁿

| Uses | Description | 
| [wp_unschedule_hook()](https://developer.wordpress.org/reference/functions/wp_unschedule_hook/)`wp-includes/cron.php` |

Unschedules all events attached to the hook.

  | 
| [wp_install_maybe_enable_pretty_permalinks()](https://developer.wordpress.org/reference/functions/wp_install_maybe_enable_pretty_permalinks/)`wp-admin/includes/upgrade.php` |

Maybe enable pretty permalinks on installation.

  | 
| [populate_roles()](https://developer.wordpress.org/reference/functions/populate_roles/)`wp-admin/includes/schema.php` |

Execute WordPress role creation for the various WordPress versions.

  | 
| [populate_options()](https://developer.wordpress.org/reference/functions/populate_options/)`wp-admin/includes/schema.php` |

Create WordPress options and set the default values.

  | 
| [wp_check_mysql_version()](https://developer.wordpress.org/reference/functions/wp_check_mysql_version/)`wp-admin/includes/upgrade.php` |

Checks the version of the installed MySQL binary.

  | 
| [make_db_current_silent()](https://developer.wordpress.org/reference/functions/make_db_current_silent/)`wp-admin/includes/upgrade.php` |

Updates the database tables to a new schema, but without displaying results.

  | 
| [wp_install_defaults()](https://developer.wordpress.org/reference/functions/wp_install_defaults/)`wp-admin/includes/upgrade.php` |

Creates the initial content for a newly-installed site.

  | 
| [wp_new_blog_notification()](https://developer.wordpress.org/reference/functions/wp_new_blog_notification/)`wp-admin/includes/upgrade.php` |

Notifies the site admin that the installation of WordPress is complete.

  | 
| [WP_User::__construct()](https://developer.wordpress.org/reference/classes/wp_user/__construct/)`wp-includes/class-wp-user.php` |

Constructor.

  | 
| [wp_schedule_event()](https://developer.wordpress.org/reference/functions/wp_schedule_event/)`wp-includes/cron.php` |

Schedules a recurring event.

  | 
| [wp_cache_flush()](https://developer.wordpress.org/reference/functions/wp_cache_flush/)`wp-includes/cache.php` |

Removes all cache items.

  | 
| [wp_generate_password()](https://developer.wordpress.org/reference/functions/wp_generate_password/)`wp-includes/pluggable.php` |

Generates a random password drawn from the defined set of characters.

  | 
| [wp_guess_url()](https://developer.wordpress.org/reference/functions/wp_guess_url/)`wp-includes/functions.php` |

Guesses the URL for the site.

  | 
| [wp_create_user()](https://developer.wordpress.org/reference/functions/wp_create_user/)`wp-includes/user.php` |

Provides a simpler way of inserting a user into the database.

  | 
| [wp_update_user()](https://developer.wordpress.org/reference/functions/wp_update_user/)`wp-includes/user.php` |

Updates a user in the database.

  | 
| [username_exists()](https://developer.wordpress.org/reference/functions/username_exists/)`wp-includes/user.php` |

Determines whether the given username exists.

  | 
| [update_user_meta()](https://developer.wordpress.org/reference/functions/update_user_meta/)`wp-includes/user.php` |

Updates user meta field based on user ID.

  | 
| [flush_rewrite_rules()](https://developer.wordpress.org/reference/functions/flush_rewrite_rules/)`wp-includes/rewrite.php` |

Removes rewrite rules and then recreate rewrite rules.

  | 
| [__()](https://developer.wordpress.org/reference/functions/__/)`wp-includes/l10n.php` |

Retrieves the translation of $text.

  | 
| [_deprecated_argument()](https://developer.wordpress.org/reference/functions/_deprecated_argument/)`wp-includes/functions.php` |

Marks a function argument as deprecated and inform when it has been used.

  | 
| [do_action()](https://developer.wordpress.org/reference/functions/do_action/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to an action hook.

  | 
| [update_option()](https://developer.wordpress.org/reference/functions/update_option/)`wp-includes/option.php` |

Updates the value of an option that was already added.

  |

[Show 17 more](https://developer.wordpress.org/reference/functions/wp_install/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/wp_install/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/wp_install/?output_format=md#changelog)󠁿

| Version | Description | 
| [2.1.0](https://developer.wordpress.org/reference/since/2.1.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_install%2F)
before being able to contribute a note or feedback.