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

Introduce new filter, 'aad_insert_user_data' #231

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions aad-sso-wordpress.php
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,15 @@ function get_wp_user_from_aad_user( $jwt, $group_memberships ) {
'user_pass' => null,
);

/**
* Filters the userdata before inserting the user into WordPress.
*
* @since 1.1.0
*
* @param array $userdata Userdata array before inserting.
*/
$userdata = apply_filters( 'aad_insert_user_data', $userdata );

$new_user_id = wp_insert_user( $userdata );

if ( is_wp_error( $new_user_id ) ) {
Expand All @@ -458,11 +467,11 @@ function get_wp_user_from_aad_user( $jwt, $group_memberships ) {
'user_not_registered',
sprintf(
__( 'ERROR: Error creating user \'%s\'.', 'aad-sso-wordpress' ),
$unique_name
$userdata['user_login']
)
);
} else {
AADSSO::debug_log( 'Created new user: \'' . $unique_name . '\', user id ' . $new_user_id . '.' );
AADSSO::debug_log( 'Created new user: \'' . $userdata['user_login'] . '\', user id ' . $new_user_id . '.' );
$user = new WP_User( $new_user_id );
}
} else {
Expand Down