wppaste
WordPress

validate_another_blog_signup(): null|bool

Since
MU (3.0.0)
Source
wp-signup.php:431
Validates a new site sign-up for an existing user.

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.

Return value

null|bool
True if site signup was validated, false on error.
The function halts all execution if the user is not logged in.

Performance profile

How much work a call to validate_another_blog_signup() 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
Light

Only touches the object cache, via wp_cache_set_sites_last_changed().

Scaling
Constant

No loop in the body: the same number of instructions runs whatever you pass in.

Instructions
33–103

Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 110.

Plugin surface
2 hooks

Third-party callbacks on 'signup_create_blog_meta', 'add_signup_meta' run inside this call, and their cost is not bounded by anything here.

Called by
0

Nothing in core calls this; the cost is only what you spend yourself.

What it touches

  • hookthird-party callbacksapply_filters_deprecated()called directly
  • cacheobject cachewp_cache_set_sites_last_changed()one call below validate_another_blog_signup()

Further down the call graph this can also reach option, query, serialize, transient and http. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.

What one call costs · 14 distinct outcomes

One number would be a lie: the work depends on which branch runs. These are every distinct cost validate_another_blog_signup() can have, taken from its control-flow graph on PHP 8.5.

WhenInstructionsCalls it makes
is_user_logged_in() && ->has_errors()33wp_get_current_user(), is_user_logged_in(), validate_blog_form(), ->has_errors(), signup_another_blog()
!is_user_logged_in() && ->has_errors()35wp_get_current_user(), is_user_logged_in(), exit(), validate_blog_form(), ->has_errors(), signup_another_blog()
is_user_logged_in() && !->has_errors() && empty($value) && is_wp_error()67wp_get_current_user(), is_user_logged_in(), validate_blog_form(), ->has_errors(), apply_filters(), get_current_network_id(), wpmu_create_blog(), is_wp_error()
!is_user_logged_in() && !->has_errors() && empty($value) && is_wp_error()69wp_get_current_user(), is_user_logged_in(), exit(), validate_blog_form(), ->has_errors(), apply_filters(), get_current_network_id(), wpmu_create_blog(), is_wp_error()
is_user_logged_in() && !->has_errors() && !empty($value) && !$languages && is_wp_error()75wp_get_current_user(), is_user_logged_in(), validate_blog_form(), ->has_errors(), signup_get_available_languages(), apply_filters(), get_current_network_id(), wpmu_create_blog(), is_wp_error()
!is_user_logged_in() && !->has_errors() && !empty($value) && !$languages && is_wp_error()77wp_get_current_user(), is_user_logged_in(), exit(), validate_blog_form(), ->has_errors(), signup_get_available_languages(), apply_filters(), get_current_network_id(), wpmu_create_blog(), is_wp_error()
is_user_logged_in() && !->has_errors() && empty($value) && !is_wp_error()80wp_get_current_user(), is_user_logged_in(), validate_blog_form(), ->has_errors(), apply_filters(), get_current_network_id(), wpmu_create_blog(), is_wp_error(), confirm_another_blog_signup()
!is_user_logged_in() && !->has_errors() && empty($value) && !is_wp_error()82wp_get_current_user(), is_user_logged_in(), exit(), validate_blog_form(), ->has_errors(), apply_filters(), get_current_network_id(), wpmu_create_blog(), is_wp_error(), confirm_another_blog_signup()
is_user_logged_in() && !->has_errors() && !empty($value) && $languages && is_wp_error()86–88wp_get_current_user(), is_user_logged_in(), validate_blog_form(), ->has_errors(), signup_get_available_languages(), sanitize_text_field(), wp_unslash(), apply_filters(), get_current_network_id(), wpmu_create_blog(), is_wp_error()
is_user_logged_in() && !->has_errors() && !empty($value) && !$languages && !is_wp_error()88wp_get_current_user(), is_user_logged_in(), validate_blog_form(), ->has_errors(), signup_get_available_languages(), apply_filters(), get_current_network_id(), wpmu_create_blog(), is_wp_error(), confirm_another_blog_signup()
!is_user_logged_in() && !->has_errors() && !empty($value) && $languages && is_wp_error()88–90wp_get_current_user(), is_user_logged_in(), exit(), validate_blog_form(), ->has_errors(), signup_get_available_languages(), sanitize_text_field(), wp_unslash(), apply_filters(), get_current_network_id(), wpmu_create_blog(), is_wp_error()
!is_user_logged_in() && !->has_errors() && !empty($value) && !$languages && !is_wp_error()90wp_get_current_user(), is_user_logged_in(), exit(), validate_blog_form(), ->has_errors(), signup_get_available_languages(), apply_filters(), get_current_network_id(), wpmu_create_blog(), is_wp_error(), confirm_another_blog_signup()
2 further outcomes, up to 103 instructions
is_user_logged_in() && !->has_errors() && !empty($value) && $languages && !is_wp_error()99–101wp_get_current_user(), is_user_logged_in(), validate_blog_form(), ->has_errors(), signup_get_available_languages(), sanitize_text_field(), wp_unslash(), apply_filters(), get_current_network_id(), wpmu_create_blog(), is_wp_error(), confirm_another_blog_signup()
!is_user_logged_in() && !->has_errors() && !empty($value) && $languages && !is_wp_error()101–103wp_get_current_user(), is_user_logged_in(), exit(), validate_blog_form(), ->has_errors(), signup_get_available_languages(), sanitize_text_field(), wp_unslash(), apply_filters(), get_current_network_id(), wpmu_create_blog(), is_wp_error(), confirm_another_blog_signup()

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev11033–1036
8.511033–1036
8.411033–10362 fewer instructions than PHP 8.3
8.311212–1046
8.211212–1046
8.111212–1046
7.411212–1046

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 validate_another_blog_signup() runs, in this order:

  1. do_action( signup_create_blog_meta )filter_deprecatedline 483 (+52 into the body)

    Filters the new site meta variables.

  2. apply_filters( add_signup_meta )filterline 497 (+66 into the body)

    Filters the new default site meta variables.

Uses · 13

Show all 13

Source code

function validate_another_blog_signup() {	global $blogname, $blog_title, $errors, $domain, $path;	$current_user = wp_get_current_user();	if ( ! is_user_logged_in() ) {		die();	} 	$result = validate_blog_form(); 	// Extracted values set/overwrite globals.	$domain     = $result['domain'];	$path       = $result['path'];	$blogname   = $result['blogname'];	$blog_title = $result['blog_title'];	$errors     = $result['errors']; 	if ( $errors->has_errors() ) {		signup_another_blog( $blogname, $blog_title, $errors );		return false;	} 	$public = (int) $_POST['blog_public']; 	$blog_meta_defaults = array(		'lang_id' => 1,		'public'  => $public,	); 	// Handle the language setting for the new site.	if ( ! empty( $_POST['WPLANG'] ) ) { 		$languages = signup_get_available_languages(); 		if ( in_array( $_POST['WPLANG'], $languages, true ) ) {			$language = wp_unslash( sanitize_text_field( $_POST['WPLANG'] ) ); 			if ( $language ) {				$blog_meta_defaults['WPLANG'] = $language;			}		}	} 	/**	 * Filters the new site meta variables.	 *	 * Use the {@see 'add_signup_meta'} filter instead.	 *	 * @since MU (3.0.0)	 * @deprecated 3.0.0 Use the {@see 'add_signup_meta'} filter instead.	 *	 * @param array $blog_meta_defaults An array of default blog meta variables.	 */	$meta_defaults = apply_filters_deprecated( 'signup_create_blog_meta', array( $blog_meta_defaults ), '3.0.0', 'add_signup_meta' ); 	/**	 * Filters the new default site meta variables.	 *	 * @since 3.0.0	 *	 * @param array $meta {	 *     An array of default site meta variables.	 *	 *     @type int $lang_id     The language ID.	 *     @type int $blog_public Whether search engines should be discouraged from indexing the site. 1 for true, 0 for false.	 * }	 */	$meta = apply_filters( 'add_signup_meta', $meta_defaults ); 	$blog_id = wpmu_create_blog( $domain, $path, $blog_title, $current_user->ID, $meta, get_current_network_id() ); 	if ( is_wp_error( $blog_id ) ) {		return false;	} 	confirm_another_blog_signup( $domain, $path, $blog_title, $current_user->user_login, $current_user->user_email, $meta, $blog_id );	return true;}

Changelog

Introduced in MU (3.0.0). Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 6.7.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.