I’m in the process of learning how to code a plugin and ran into a problem. I’m not quite sure why this is happening. I think it has something to do with member_id being passed to the plugin as a string and not an integer. So here’s my problem…
{exp:my_class:my_function aff_id="{member_id}"}
If I pass the member_id like this to a custom DB query in the plugin, it doesn’t pull the correct results. BUT, if I replace the {member_id} with say “2”, it works perfectly. I’ve also confirmed that the logged in member_id is currently “2”.
Any suggestions? Have I missed something obvious here?
I’ll probably shift this down to the plugin development forum where it’s a better fit. But I’m fuzzy on why you need to pass the member id at all if it’s for whoever is viewing the page- couldn’t you use the session class and grab it via the plugin?
I’d definitely go with Robin on this one and use the session class to grab the value.
All you’d need is something like this to return the value you are after :
$plugin_member_id = $SESS->userdata['member_id'];
That should give you the correct value inside your plugin that you can then use as you see fit.
Let us know if that is any good for you?
Best wishes,
Mark
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.