Jump to content

Extension talk:WSOAuth/Hooks/WSOAuthAfterGetUser

Add topic

Getting the User's Real Name as a PHP variable in LocalSettings

[edit]

How could this hook be used in localsettings.php to store the text of the user's Real Name? Is it as simple as something like:

public static function onWSOAuthAfterGetUser( &$user_info, &$errorMessage ) {

  $TheUsersRealName = $user['Real Name'];

}

$wgHooks['WSOAuthAfterGetUser'][] = 'MyExtensionHooks::onWSOAuthAfterGetUser';


Revansx (talk) 14:40, 27 April 2020 (UTC)Reply

Hi Revansx,
Something like this would expose the user's real name before it gets stored in the database and before the user is authenticated:
function onWSOAuthAfterGetUser(&$user_info, &$errorMessage) {
    $real_name = $user_info['realname'];
    # Do whatever
}
$wgHooks['WSOAuthAfterGetUser'][] = 'onWSOAuthAfterGetUser';
Xxmarijnw (talk) 15:11, 27 April 2020 (UTC)Reply
Thanks, I'm trying to set the configuration variable of extension:CreateUserPage with the value of the Real Name from the WSOAuth WSOAuthAfterGetUser Hook. But it's not working. Either the Hooks runs too late (after CreateUSerPage does its thing or i'm writing it incorrectly. The snipit below in my LocalSettings is supposed to create the user's user page with the wikitext being the Real Name from the WSOAuth Login. But it doesn't work.
wfLoadExtension( "CreateUserPage" );
$wgCreateUserPage_OnLogin = true;
function onWSOAuthAfterGetUser(&$user_info, &$errorMessage) {
$wgCreateUserPage_PageContent = $user_info['realname'];
}
$wgHooks['WSOAuthAfterGetUser'][] = 'onWSOAuthAfterGetUser';
Revansx (talk) 15:34, 27 April 2020 (UTC)Reply
PluggableAuth redirects shortly after this hook is called. When the CreateUserPage extension tries to read the variable, it is no longer set. Xxmarijnw (talk) 17:14, 27 April 2020 (UTC)Reply
gotcha.. hmm Revansx (talk) 17:19, 27 April 2020 (UTC)Reply