cannot compare logged_in_member_id to member_id within exp:user:edit
Posted: 10 September 2008 02:49 AM   [ Ignore ]
Newbie
Rank
Total Posts:  21
Joined  2008-08-07

i’m attempting to determine whether a member is editing their own member profile.

obvious solution is

{if logged_in_member_id == member_id}

but the parser appears to be finding and substituting the MEMBER_ID portion first, then generating a parsing error. if for example the member_id is MYNAME then it’s barfing because it ends up with

{if logged_in_MYNAME == "MYNAME"}

i imagine that exp:user:edit does a sort of primitive tag replacement which doesnt look for longer tags before shorter ones?

anyway how can i determine whether a member is editing their own profile from within exp:user:edit ?

Profile
 
 
Posted: 11 September 2008 06:37 AM   [ Ignore ]   [ # 1 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  3356
Joined  2006-10-18

fogcity,

Fortunately we’ve created a function for this:

User “Is Mine” Documentation

The example below is how you might use the IS MINE function on the User:Edit form, pulling the Member ID from the third segment of the URL. smile

{exp:user:is_mine member_id="{segment_3}"}

{if mine}This profile is mine
, or I am a super admin.{/if}
{if not_mine}Eat my shorts
.{/if}

{exp
:user:edit return="user"}

<p>Location <input name="location" value="{location}" /></p>
<
p>Email <input name="email" value="{email}" /></p>
<
p>Username <input name="username" value="{username}" /></p>
<
p>Screen Name <input name="screen_name" value="{screen_name}" /></p>
<
p>Password <input type="password" name="password" value="" /></p>
<
p>Password Confirm <input type="password" name="password_confirm" value="" /></p>
<
p>Current Password <input type="password" name="current_password" value="" /></p>
<
p><input type="submit" value="Submit" /></p>

{/exp:user:edit}

{
/exp:user:is_mine}

 Signature 
Profile
 
 
Posted: 16 September 2008 11:52 AM   [ Ignore ]   [ # 2 ]
Newbie
Rank
Total Posts:  21
Joined  2008-08-07

ok… except it doesn’t work for me:

{exp:user:users}
{exp
:user:is_mine member_id="{member_id}"}
  {if mine} {screen_name} is MINE
! {/if}
{
/exp:user:is_mine}
{
/exp:user:users}

produces this output:

Dan is MINE! Mary is MINE! Sally is MINE!

in other words, {mine} is always true.

note that my ultimate goal is to print out a list of all members of a certain member group, PLUS the currently logged in user… all sorted by screen name. would be a snap if i could compare {member_id} to {logged_in_member_id} but the parsing bug in exp:user:users prevents that.

Profile
 
 
Posted: 16 September 2008 12:17 PM   [ Ignore ]   [ # 3 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  3356
Joined  2006-10-18

Ok, but why are you using the User:Users list to Edit a profile?

 Signature 
Profile
 
 
Posted: 16 September 2008 12:38 PM   [ Ignore ]   [ # 4 ]
Newbie
Rank
Total Posts:  21
Joined  2008-08-07

I’m not.

I’m using it to list all the members that the current user is permitted to see. they can click on a particular user in the list to bring up the edit page, which uses the edit tag. Just like it works in EE’s control panel, but with a little extra filtering of members applied.

Again, the goal is to list members belonging to a particular group, plus the currently logged in user. Is the bottom line that this isnt possible with the User module?

Profile
 
 
Posted: 16 September 2008 01:11 PM   [ Ignore ]   [ # 5 ]
Newbie
Rank
Total Posts:  21
Joined  2008-08-07

Cancel that order. 

Can access logged_in_member_id via PHP

Profile