signup_another_blog( string $blogname = '', string $blog_title = '', WP_Error|string $errors = '' )
- Since
- MU (3.0.0)
- Source
wp-signup.php:339
Compatibility
- WordPress
- since MU (3.0.0)
- PHP
- 7.4–8.6-dev
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.
Parameters
$blognamestringoptional- The new site nameDefault:
'' $blog_titlestringoptional- The new site title.Default:
'' $errorsWP_Error|stringoptional- A WP_Error object containing existing errors. Defaults to empty string.Default:
''
Performance profile
How much work a call to signup_another_blog() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.
- Cost class
- Heavy
- Scaling
- Scales with input
- Instructions
- 80–98
- Plugin surface
- 2 hooks
- Called by
- 1
Reads stored settings via get_option(), cached per request but not free on a cold cache.
The body loops, so the work grows with what you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 113.
Third-party callbacks on 'signup_another_blog_init', 'signup_hidden_fields' run inside this call, and their cost is not bounded by anything here.
1 place in core call this, so the cost is paid more often than your own code shows.
What it touches
- hookthird-party callbacks
apply_filters()called directly - optionoption read or write
get_option()one call below signup_another_blog()
Further down the call graph this can also reach cache, serialize, transient, http and query. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.
What one call costs · 4 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost signup_another_blog() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
!->has_errors() && empty($blogs) | 80–83 | wp_get_current_user(), is_wp_error(), apply_filters(), __(), get_network(), sprintf(), ->has_errors(), __(), printf(), get_blogs_of_user(), _e(), do_action(), show_blog_form(), esc_attr_e() |
->has_errors() && empty($blogs) | 86–89 | wp_get_current_user(), is_wp_error(), apply_filters(), __(), get_network(), sprintf(), ->has_errors(), __(), __(), printf(), get_blogs_of_user(), _e(), do_action(), show_blog_form(), esc_attr_e() |
!->has_errors() && !empty($blogs) | 88–92 | wp_get_current_user(), is_wp_error(), apply_filters(), __(), get_network(), sprintf(), ->has_errors(), __(), printf(), get_blogs_of_user(), _e(), _e(), do_action(), show_blog_form(), esc_attr_e() |
->has_errors() && !empty($blogs) | 94–98 | wp_get_current_user(), is_wp_error(), apply_filters(), __(), get_network(), sprintf(), ->has_errors(), __(), __(), printf(), get_blogs_of_user(), _e(), _e(), do_action(), show_blog_form(), esc_attr_e() |
Across PHP versions
Compiles the same on PHP 7.4, 8.1, 8.2, 8.3, 8.4, 8.5 and 8.6-dev: 113 instructions, 80–98 executed per call, 5 branches. The work does not change between versions.
An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.
Hooks and filters fired · 2
2 hooks fire while signup_another_blog() runs, in this order:
- apply_filters( signup_another_blog_init )filterline 365 (+26 into the body)
Filters the default site sign-up variables.
- do_action( signup_hidden_fields )actionline 416 (+77 into the body)
Fires when hidden sign-up form fields output when creating another site or user.
Uses · 13
- wp_get_current_user()Retrieves the current user object.
- is_wp_error()Checks whether the given variable is a WordPress Error.
- apply_filters()Calls the callback functions that have been added to a filter hook.
- __()Retrieves the translation of $text.
- get_network()Retrieves network data given a network ID or network object.
- get_blogs_of_user()Gets the sites a user belongs to.
- _e()Displays translated text.
- get_home_url()Retrieves the URL for a given site where the front end is accessible.
- esc_url()Checks and cleans a URL.
- do_action()Calls the callback functions that have been added to an action hook.
- show_blog_form()Generates and displays the Sign-up and Create Site forms.
- esc_attr_e()Displays translated text that has been escaped for safe use in an attribute.
Show all 13
- WP_Error::__construct()Initializes the error.
Used by · 1
- validate_another_blog_signup()Validates a new site sign-up for an existing user.
Source code
function signup_another_blog( $blogname = '', $blog_title = '', $errors = '' ) { $current_user = wp_get_current_user(); if ( ! is_wp_error( $errors ) ) { $errors = new WP_Error(); } $signup_defaults = array( 'blogname' => $blogname, 'blog_title' => $blog_title, 'errors' => $errors, ); /** * Filters the default site sign-up variables. * * @since 3.0.0 * * @param array $signup_defaults { * An array of default site sign-up variables. * * @type string $blogname The site blogname. * @type string $blog_title The site title. * @type WP_Error $errors A WP_Error object possibly containing 'blogname' or 'blog_title' errors. * } */ $filtered_results = apply_filters( 'signup_another_blog_init', $signup_defaults ); $blogname = $filtered_results['blogname']; $blog_title = $filtered_results['blog_title']; $errors = $filtered_results['errors']; /* translators: %s: Network title. */ echo '<h2>' . sprintf( __( 'Get <em>another</em> %s site in seconds' ), get_network()->site_name ) . '</h2>'; if ( $errors->has_errors() ) { echo '<p>' . __( 'There was a problem, please correct the form below and try again.' ) . '</p>'; } ?> <p> <?php printf( /* translators: %s: Current user's display name. */ __( 'Welcome back, %s. By filling out the form below, you can <strong>add another site to your account</strong>. There is no limit to the number of sites you can have, so create to your heart’s content, but write responsibly!' ), $current_user->display_name ); ?> </p> <?php $blogs = get_blogs_of_user( $current_user->ID ); if ( ! empty( $blogs ) ) { ?> <p><?php _e( 'Sites you are already a member of:' ); ?></p> <ul> <?php foreach ( $blogs as $blog ) { $home_url = get_home_url( $blog->userblog_id ); echo '<li><a href="' . esc_url( $home_url ) . '">' . $home_url . '</a></li>'; } ?> </ul> <?php } ?> <p><?php _e( 'If you are not going to use a great site domain, leave it for a new user. Now have at it!' ); ?></p> <form id="setupform" method="post" action="wp-signup.php"> <input type="hidden" name="stage" value="gimmeanotherblog" /> <?php /** * Fires when hidden sign-up form fields output when creating another site or user. * * @since MU (3.0.0) * * @param string $context A string describing the steps of the sign-up process. The value can be * 'create-another-site', 'validate-user', or 'validate-site'. */ do_action( 'signup_hidden_fields', 'create-another-site' ); ?> <?php show_blog_form( $blogname, $blog_title, $errors ); ?>Changelog
Introduced in MU (3.0.0). Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 6.9.7 tag, from
src/wp-signup.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.