Jump to content

Extension talk:WSOAuth/Hooks/WSOAuthAfterGetUser

About this board

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

5
Revansx (talkcontribs)

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';


Xxmarijnw (talkcontribs)

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';
Revansx (talkcontribs)

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';
Xxmarijnw (talkcontribs)

PluggableAuth redirects shortly after this hook is called. When the CreateUserPage extension tries to read the variable, it is no longer set.

Revansx (talkcontribs)

gotcha.. hmm

Reply to "Getting the User's Real Name as a PHP variable in LocalSettings"
There are no older topics