Skip to content

Commit 7526183

Browse files
committed
bug: Fixed issue wth wp_login action missing object
1 parent a251291 commit 7526183

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

onelogin-saml-sso/php/functions.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -460,9 +460,16 @@ function saml_acs() {
460460

461461
do_action( 'onelogin_saml_attrs', $attrs, wp_get_current_user(), get_current_user_id() );
462462

463-
$triggerWPLoginHook = get_site_option('onelogin_saml_trigger_login_hook');
464-
if ($triggerWPLoginHook) {
465-
do_action( 'wp_login', $user->user_login, $user );
463+
// Trigger the wp_login hook used by wp_signon()
464+
// @see https://developer.wordpress.org/reference/hooks/wp_login/
465+
$trigger_wp_login_hook = get_site_option( 'onelogin_saml_trigger_login_hook' );
466+
467+
if ( $trigger_wp_login_hook ) {
468+
$user = get_user_by( 'id', $user_id );
469+
470+
if ( false !== $user ) {
471+
do_action( 'wp_login', $user->user_login, $user );
472+
}
466473
}
467474

468475
if (isset($_REQUEST['RelayState'])) {

0 commit comments

Comments
 (0)