Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added filter and hooks for find_by_email_or_create #92

Closed
wants to merge 6 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 24 additions & 1 deletion src/admin/class-sign-in-with-google-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,15 @@ protected function find_by_email_or_create( $user_data ) {

// Redirect the user if registrations are disabled and there is no domain user registration override.
if ( false === $user && ! $allow_domain_user_registration && ! $allow_user_registration ) {
wp_redirect( site_url( 'wp-login.php?registration=disabled' ) );
/**
* Adjust where users are redirected if new user registrations are disabled.
*
* @since [NEXT]
*
* @param string The redirection URL.
*/
$redirect = apply_filters( 'siwg_registrations_disabled_redirect', site_url( 'wp-login.php?registration=disabled' ) );
wp_redirect( $redirect );
exit;
}

Expand Down Expand Up @@ -786,7 +794,22 @@ protected function find_by_email_or_create( $user_data ) {
'role' => $role,
);

/**
* Adjust the user data before new user is created.
*
* @since [NEXT]
*
* @param array The new user array.
* @param object The user_data object returned by Google.
*/
$user = apply_filters( 'siwg_new_user_data', $user, $user_data );
$new_user = wp_insert_user( $user );
/**
* Fires after a new user is created from a new Google account.
*
* @since [NEXT]
*/
do_action( 'siwg_after_create_new_user', $new_user );

if ( is_wp_error( $new_user ) ) {
wp_die( $new_user->get_error_message() . ' <a href="' . wp_login_url() . '">Return to Log In</a>' );
Expand Down