WordPress.org

Make WordPress Core

Opened 2 years ago

Closed 9 months ago

#17306 closed defect (bug) (fixed)

The filter wpmu_validate_blog_signup cannot is not passed enough parameters

Reported by: BrianLayman Owned by: nacin
Priority: normal Milestone: 3.5
Component: Multisite Version: 3.1
Severity: normal Keywords: has-patch
Cc:

Description (last modified by dd32)

The function call wpmu_validate_blog_signup is passed $blogname, $blog_title and $user

When writing a plugin using the wpmu_validate_blog_signup filter to replace the existing check, you cannot handle the condition of the blogname being that of an existing user that is not the current logged in user.
e.g. this section of code from the original function:

	if ( username_exists( $blogname ) ) {
		if ( is_object( $user ) == false || ( is_object($user) && ( $user->user_login != $blogname ) ) )
			$errors->add( 'blogname', __( 'Sorry, that site is reserved!' ) );
	}

The original functions should perhaps replace the line:
$result = array('domain' => $mydomain, 'path' => $path, 'blogname' => $blogname, 'blog_title' => $blog_title, 'errors' => $errors);

with:
$result = array('domain' => $mydomain, 'path' => $path, 'blogname' => $blogname, 'blog_title' => $blog_title, 'user' => $user, 'errors' => $errors);

The only problem I see with this is the possibility of some plugin referencing the fifth position of $result by numeric index instead of by name, which would be a really wrong thing to do. So I think this implementation should not be a problem.

Attachments (1)

17306.patch (694 bytes) - added by jakub.tyrcha 2 years ago.

Download all attachments as: .zip

Change History (6)

jakub.tyrcha2 years ago

comment:1 jakub.tyrcha2 years ago

why not just add the 'user' parameter in the end?

comment:2 dd322 years ago

  • Description modified (diff)
  • Keywords has-patch added

comment:3 SergeyBiryukov22 months ago

  • Component changed from General to Multisite

comment:4 wonderboymusic9 months ago

  • Milestone changed from Awaiting Review to 3.5

There are a lot of these Multisite one-liners out there. Bumping up.

comment:5 nacin9 months ago

  • Owner set to nacin
  • Resolution set to fixed
  • Status changed from new to closed

In [21860]:

Pass the user parameter to the wpmu_validate_blog_signup filter and wpmu_validate_blog_signup()'s return array. props BrianLayman. fixes #17306.

Note: See TracTickets for help on using tickets.