Make WordPress Core

Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#33631 closed enhancement (fixed)

Add filter to prevent user creation during site creation

Reported by: mackensen's profile mackensen Owned by: rachelbaker's profile rachelbaker
Milestone: 4.5 Priority: normal
Severity: normal Version: 4.4
Component: Networks and Sites Keywords: has-patch commit
Focuses: multisite Cc:

Description

We administer a multisite environment with external (LDAP) authentication configured. We do not allow local accounts. Our procedure when creating a new site is to add the soon-to-be-administrator from external authentication to the top-level site (if they did not already exist) before creating the site. If someone misses that first step, we wind up with an unwanted local account which then has to be fixed. What would be cool is a filter/hook in wp-admin/network/site-new.php that attaches to email_exists and lets you stop the site creation process if the user doesn't exist.

Attachments (4)

33631.diff (715 bytes) - added by mackensen 10 years ago.
33631-fixed.diff (718 bytes) - added by mackensen 10 years ago.
Corrected param type
33631.patch (757 bytes) - added by rachelbaker 10 years ago.
Fixed spacing and added version to inline docs
33631.2.diff (787 bytes) - added by jeremyfelt 10 years ago.

Download all attachments as: .zip

Change History (14)

#1 @SergeyBiryukov
10 years ago

  • Component changed from Administration to Networks and Sites

A workaround:

function wp33631_check_for_existing_user_during_site_creation() {	if ( ! isset( $_REQUEST['action'] ) || 'add-site' !== $_REQUEST['action'] ) {	return;	}	if ( ! email_exists( $_POST['blog']['email'] ) ) {	wp_die( 'User does not exist.' );	} } add_action( 'admin_init', 'wp33631_check_for_existing_user_during_site_creation' ); 

@mackensen
10 years ago

#2 @mackensen
10 years ago

Working on this at WCUS Contributor Day. I've added a new action network_site_new_created_user_pending which fires immediately before user creation, so you could hook into it with a simple wp_die or whatever else you might want to do. I could see external auth attempting to auto provision the account.

#3 @rachelbaker
10 years ago

@mackensen Looks like you have wrong parameter type in the inline docs for the filter. Can you check it?

#4 @rachelbaker
10 years ago

  • Keywords has-patch needs-refresh dev-feedback added

@mackensen
10 years ago

Corrected param type

@rachelbaker
10 years ago

Fixed spacing and added version to inline docs

#5 @rachelbaker
10 years ago

  • Keywords commit added; needs-refresh dev-feedback removed

#6 @rachelbaker
10 years ago

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

In 35786:

Multisite: Add hook before a new user is created during the creation of a new site.

New network_site_new_created_user_pending action fires before a new user will be created via the network site-new.php page.

Props mackensen
Fixes #33631

@jeremyfelt
10 years ago

#7 @jeremyfelt
10 years ago

  • Milestone changed from Awaiting Review to 4.5
  • Resolution fixed deleted
  • Status changed from closed to reopened

We can probably tighten up the naming on this a bit to be more clear. Nothing is pending yet, as we still need to go through some other user checks to see if the email is valid before continuing. Using pre_ seems to make sense. I've added 33631.2.diff with this change.

Thoughts?

#8 @rachelbaker
10 years ago

In 35789:

Multisite: Clarify purpose of hook from [35786] and match our naming convention.

network_site_new_created_user_pending -> pre_network_site_new_created_user

See #33631

#9 @rachelbaker
10 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

#10 @DrewAPicture
10 years ago

In 36826:

Docs: Minorly improve the hook doc summary for the pre_network_site_new_created_user action, introduced in [35786].

See #33631. See #35986.

Note: See TracTickets for help on using tickets.