On this page
signup_blog( string $user_name = '', string $user_email = '', string $blogname = '', string $blog_title = '', WP_Error|string $errors = '' )
Shows a form for a user or visitor to sign up for a new site.
Parameters
$user_namestring Optional-
The username.
Default:
'' $user_emailstring Optional-
The user's email address.
Default:
'' $blognamestring Optional-
The site name.
Default:
'' $blog_titlestring Optional-
The site title.
Default:
'' $errorsWP_Error|string Optional-
A WP_Error object containing existing errors. Defaults to empty string.
Default:
''
Source
File: wp-signup.php. View all references
function signup_blog( $user_name = '', $user_email = '', $blogname = '', $blog_title = '', $errors = '' ) {
if ( ! is_wp_error( $errors ) ) {
$errors = new WP_Error();
}
$signup_blog_defaults = array(
'user_name' => $user_name,
'user_email' => $user_email,
'blogname' => $blogname,
'blog_title' => $blog_title,
'errors' => $errors,
);
/**
* Filters the default site creation variables for the site sign-up form.
*
* @since 3.0.0
*
* @param array $signup_blog_defaults {
* An array of default site creation variables.
*
* @type string $user_name The user username.
* @type string $user_email The user email address.
* @type string $blogname The blogname.
* @type string $blog_title The title of the site.
* @type WP_Error $errors A WP_Error object with possible errors relevant to new site creation variables.
* }
*/
$filtered_results = apply_filters( 'signup_blog_init', $signup_blog_defaults );
$user_name = $filtered_results['user_name'];
$user_email = $filtered_results['user_email'];
$blogname = $filtered_results['blogname'];
$blog_title = $filtered_results['blog_title'];
$errors = $filtered_results['errors'];
if ( empty( $blogname ) ) {
$blogname = $user_name;
}
?>
<form id="setupform" method="post" action="wp-signup.php">
<input type="hidden" name="stage" value="validate-blog-signup" />
<input type="hidden" name="user_name" value="<?php echo esc_attr( $user_name ); ?>" />
<input type="hidden" name="user_email" value="<?php echo esc_attr( $user_email ); ?>" />
<?php
/** This action is documented in wp-signup.php */
do_action( 'signup_hidden_fields', 'validate-site' );
?>
<?php show_blog_form( $blogname, $blog_title, $errors ); ?>
<p class="submit"><input type="submit" name="submit" class="submit" value="<?php esc_attr_e( 'Sign up' ); ?>" /></p>
</form>
<?php
}
Hooks
- apply_filters( 'signup_blog_init',
array $signup_blog_defaults ) -
Filters the default site creation variables for the site sign-up form.
- do_action( 'signup_hidden_fields',
string $context ) -
Hidden sign-up form fields output when creating another site or user.
Related
Uses
| Uses | Description |
|---|---|
| show_blog_form() wp-signup.php | Generates and displays the Sign-up and Create Site forms. |
| esc_attr_e() wp-includes/l10n.php | Displays translated text that has been escaped for safe use in an attribute. |
| esc_attr() wp-includes/formatting.php | Escaping for HTML attributes. |
| apply_filters() wp-includes/plugin.php | Calls the callback functions that have been added to a filter hook. |
| do_action() wp-includes/plugin.php | Calls the callback functions that have been added to an action hook. |
| is_wp_error() wp-includes/load.php | Checks whether the given variable is a WordPress Error. |
| WP_Error::__construct() wp-includes/class-wp-error.php | Initializes the error. |
Used By
| Used By | Description |
|---|---|
| validate_user_signup() wp-signup.php | Validates the new user sign-up. |
| validate_blog_signup() wp-signup.php | Validates new site signup. |
Changelog
| Version | Description |
|---|---|
| MU (3.0.0) | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/signup_blog