Statement that checks if it's "you"

Discussion forum for MOD Writers regarding MOD Development.
Locked
Gnasty
Registered User
Posts: 3
Joined: Sat Aug 25, 2012 11:49 pm

Statement that checks if it's "you"

Post by Gnasty »

Hi there,

I'm looking for an IF statement that checks if you are the same person as the one you see on a profile page. Say I'm looking at my profile page, I want a link from there that says "Edit Profile". How can I achieve this?


Thanks in advance,
Gnasty
User avatar
Saldash
Registered User
Posts: 619
Joined: Mon Nov 10, 2008 8:08 am
Location: Flintshire, UK
Name: Stuart Jackson
Contact:

Re: Statement that checks if it's "you"

Post by Saldash »

Hi,

One method of achieving this is to create a custom template variable that (in your PHP) checks the user ID of the person veiwing to the that of the person in the profile..

If you can get that to out put to a boolean result you can use the normal <!-- IF T_yourvariable --> ... <!-- Endif -->
(it's been a while since I've worked with templates so that IF statement may or may not be fully correct)
World Recoded UK - DreamHost Site of the Month winner February 2011!
Gnasty
Registered User
Posts: 3
Joined: Sat Aug 25, 2012 11:49 pm

Re: Statement that checks if it's "you"

Post by Gnasty »

Well yeah. That's kind of what I'm looking for. However, I'm not certain how I should do it in the PHP :cry:
User avatar
Saldash
Registered User
Posts: 619
Joined: Mon Nov 10, 2008 8:08 am
Location: Flintshire, UK
Name: Stuart Jackson
Contact:

Re: Statement that checks if it's "you"

Post by Saldash »

Gnasty wrote:Well yeah. That's kind of what I'm looking for. However, I'm not certain how I should do it in the PHP :cry:
If noone replies with the correct method before I get home, I'll post the edits you'd need to make.
World Recoded UK - DreamHost Site of the Month winner February 2011!
User avatar
Siropu
Registered User
Posts: 155
Joined: Mon Nov 16, 2009 6:15 pm
Location: Romania
Contact:

Re: Statement that checks if it's "you"

Post by Siropu »

Open memberlist.php and search for this line:

Code: Select all

'L_POSTS_IN_QUEUE'	=> $user->lang('NUM_POSTS_IN_QUEUE', $member['posts_in_queue']),
Add this line before it:

Code: Select all

'S_MY_PROFILE'      => ($user->data['user_id'] == $user_id) ? true : false,
In yourstyle/template/memberlist_view.html use this:

Code: Select all

<!-- IF S_MY_PROFILE --> [ <a href="url-to-profile">Edit profile</a> ]<!-- ENDIF -->
You could add the if statement after this line:

Code: Select all

<!-- IF U_SWITCH_PERMISSIONS --> [ <a href="{U_SWITCH_PERMISSIONS}">{L_USE_PERMISSIONS}</a> ]<!-- ENDIF -->
Check out my MODs.
User avatar
Saldash
Registered User
Posts: 619
Joined: Mon Nov 10, 2008 8:08 am
Location: Flintshire, UK
Name: Stuart Jackson
Contact:

Re: Statement that checks if it's "you"

Post by Saldash »

There ya go, Siropu got in there before I could

;)
World Recoded UK - DreamHost Site of the Month winner February 2011!
Gnasty
Registered User
Posts: 3
Joined: Sat Aug 25, 2012 11:49 pm

Re: Statement that checks if it's "you"

Post by Gnasty »

Awesome guys! Thanks both of you for the help! Works just the way I want it :D
Locked

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