Skip to content

Commit 49b1a93

Browse files
author
Sixto Martin
committed
Handle errors when creating new users
1 parent 392f0b3 commit 49b1a93

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

CHANGELOG.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
Changelog
22
---------
33

4-
0.3 Add support to handler where to go after login: administration panel or wordpress main page
4+
0.3 Handle errors when creating new users
5+
Use 'default_role' param to set a role for new users
6+
Add support to handler where to go after login: administration panel or wordpress main page
57
Import changes from simplesamlphp-authentication 0.7 (Fixed security issue, Cleanup, removal of deprecated function calls)
68
Rename plugin
79

simplesamlphp-authentication-extended/simplesamlphp-authentication-extended.php

+11-1
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,17 @@ function authenticate($user, $username) {
254254
}
255255

256256
$wp_uid = wp_insert_user($user_info);
257-
invalidate_password($wp_uid);
257+
258+
if ( is_object($wp_uid) && is_a($wp_uid, 'WP_Error') ) {
259+
$error = $wp_uid->get_error_messages();
260+
$error = implode("<br>", $error);
261+
$error = '<p><strong>ERROR</strong>: '.$error.'</p>';
262+
print_r($error);
263+
$errors['registerfail'] = $error;
264+
exit();
265+
}
266+
267+
invalidate_password($wp_uid);
258268
return get_user_by('login', $username);
259269
} else {
260270
$error = sprintf(__('<p><strong>ERROR</strong>: %s is not registered with this blog.

0 commit comments

Comments
 (0)