Username in login redirect notice

Discussion forum for MOD Writers regarding MOD Development.
adam1972
Registered User
Posts: 3
Joined: Sun Apr 26, 2015 11:55 am

Username in login redirect notice

Post by adam1972 »

What I am trying to do is include the logged in username in the login redirect notice, something like this :-
Welcome back username - now redirecting you to the board index

In language/en/ucp.php I have put this :-
'LOGIN_REDIRECT' => 'Welcome back %s - You are logged in<br>Now taking you to the forum index',

An in ucp.php I have put this under $template->assign_vars(array(

'LOGIN_REDIRECT' => sprintf($user->lang['LOGIN_REDIRECT'], $user->data['username']),

But can't get it to work, where am I going wrong ?
Any help would be much appreciated.
User avatar
Brf
Support Team Member
Support Team Member
Posts: 53549
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}

Re: Username in login redirect notice

Post by Brf »

$user->data['username'] should be 'Anonymous' at that point.

How are trying to display that string? Isn't it using the generic message body for that?
adam1972
Registered User
Posts: 3
Joined: Sun Apr 26, 2015 11:55 am

Re: Username in login redirect notice

Post by adam1972 »

I think it's using the generic message body from the template file, I'm using DarkFX (Prosilver based) but have heavily modified it.
The message itself is using 'LOGIN_REDIRECT' from the language file in language/en/ucp.php

Are you saying $user->data['username'] remains anonymous until you reach the forum index ?
If so is there any way around it or is my request impossible ?

I did manage successfully to add 'Logged in as USERNAME' with username color in index_body.html by adding $template->assign_vars(array(
'USERNAME' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'])
));
to index.php & then adding Logged in as {USERNAME} with IF_S_USER_LOGGED_IN to the html.
User avatar
Brf
Support Team Member
Support Team Member
Posts: 53549
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}

Re: Username in login redirect notice

Post by Brf »

While you are logging in, you are the Anonymous user.
After you transmit the login page, you are not truly logged in until the page reloads as the user.
I am not sure what data you might have in $row[], where that $row might have come from.
adam1972
Registered User
Posts: 3
Joined: Sun Apr 26, 2015 11:55 am

Re: Username in login redirect notice

Post by adam1972 »

The "Logged in as USERNAME" is on my board index so it's after login.
Also was able to do the same on the Arcade Index, but looks like I won't be able to acheive the welcome username message in the redirect notice because of the anonymous user.

Thanks very much for your help, I've now bypassed the login redirect notice so it goes straight to the index & have my welcome message there instead.

Return to “[3.0.x] MOD Writers Discussion”