I’m trying to put little “EDIT” links by posts. I want them there if either 1) The post’s author is logged in, or 2) The user is an admin.
I have to use PHP to do this, and because of EE’s flaky handling of {member_id} and {group_id}, I have to futz about with PHP variables.
So check out my code:
{if logged_in}
<?php
$member = "{member_id}";
$group = "{group_id}";
?>
{/if}
{exp:weblog:entries weblog="blognomic" limit="30" status="not draft"}
// Stuff, stuff, stuff
{if logged_in}
<?php
$author = "{author_id}";
echo $member; // debug
echo $author; // debug
echo $group; // debug
// -------------------------------------------
// IMPORTANT CONDITIONAL FOLLOWS
// -------------------------------------------
if (($member == $author) || ($group == '1') || ($group == '6')) {
echo 'The edit link goes here.'
}
?>
{/if}
A synopsis: I set $member and $group BEFORE the {exp:weblog:entries}. So these values pertain to the logged in user, not the weblog entries.
The lines marked //debug just output those variables’ values; at this point, the variables work PROPERLY. No problems.
The IMPORTANT CONDITIONAL is where things screw up. I can’t seem to compare any of those variables against anything.
This works:
if ($member) {
echo $member
}
This also works:
if(1==1) {
echo $member
}
Those both work fine. It’s when I try to compare one of those variables that it fails, and it does so by not returning anything whatsoever. Even this:
echo $member; // outputs 1
if ($member == 1) { // FAILS. Outputs nothing.
echo $member;
}
Doesn’t work at all.
Can anyone tell me what’s going on here?
SFT
