We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Pass currently logged in member_id to module --> conditional

Development and Programming

Nico Meijer's avatar
Nico Meijer
41 posts
15 years ago
Nico Meijer's avatar Nico Meijer

Hi,

(I’ll trust you to reroute this question if it’s not appropriate in the Tech support forum.)

I need to pass the currently logged in member_id to my custom module and evaluate the output of a function to ‘true’ or ‘false’.

In this case, I need to check if this user has performed a particular step in a process, indicated by the existence of a certain value in a database record.

So, I have {logged_in_member_id} at my disposal.

{exp:rollen:check_step step_id="{entry_id}" member_id="{logged_in_member_id}"}

Output on screen: false. Even when it should be true. The module sees the string “{logged_in_member_id}” coming in, instead of an integer.

{if "{exp:rollen:check_step step_id='{entry_id}' member_id='{logged_in__member_id}'}" == "true"}

  You have completed this step.

{if:else}
  ...
{/if}

No go. The module’s PHP code sees the string “{logged_in_member_id}”.

I cannot use {member_id} because it always equals 1. I cannot put it in a snippet, because {member_id} always equals 1 and “{logged_in_member_id}” always equals “{logged_in_member_id}”.

This all takes place in an embedded template. Okay, fair deal: let’s hand the member_id over to the embedded template:

{embed="shared/_babysteps" myval="{member_id}"}

{embed:myval} always equals 1, although the output in the ‘parent’ template might be 3.

{embed="shared/_babysteps" myval="{logged_in_member_id}"}

{embed:myval} always equals the string “{logged_in_member_id}”.

I am doing something wrong. I just don’t know what. But it’s driving me nuts. I’ve been hacking this litte piece of the whole app for 2 hours straight and I’m tired. 😕

Thanks for any pointers… Nico

       
Nico Meijer's avatar
Nico Meijer
41 posts
15 years ago
Nico Meijer's avatar Nico Meijer

Okay, some progress has been made after a not too undecent night’s sleep.

First, the whole thing was inside {exp:channel:entries} because of a field that was to be shown (or not). Got that out of the way. When it evaluates to “true”, I’m calling the channel again.

Second, {member_id} will show up correctly when wrapped in {exp:member:custom_profile_data}.

I think I’m on my way again… Nico

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.