So to create a dynamic link that lets the user edit her profile, I put this php code into a page, used that page as a link, and it automatically redirects to user/edit.

<?php
drupal_goto('user/'.$GLOBALS['user']->uid.'/edit');
?>

That works great for most places on the site, but I've also put it into my users' bio field. There's a line that shows up if the user hasn't added a bio yet, and after it I simply placed the edit link. Except now I realize that of course this puts the edit link on every page for every user's profile without a bio. (Obviously when user 2 clicks on user 3's "edit" link, she goes to her own profile edit section.) But what I'd prefer to happen is that user 2 would only see the edit link on his or her own profile. I know this code *should* be fairly simple(ish?), but I just can't figure out what to do. Here's the profile section:

 <div class="bio-wrapper-1"><div class="bio-wrapper"><div class="bio">
<?php $pfieldname = "profile_bio"; ?>
<?php if(($account->$pfieldname) == ""): ?>
<p>I haven't written my bio yet. <a href="mysite/url.com">Edit</a></p>
<?php endif; ?>
<?php print $account->$pfieldname ; ?>
</div></div></div>

Any ideas? Thanks in advance!

Comments

cog.rusty’s picture

You could add an if($account->uid == $GLOBALS['user']->uid) condition.

amandawolfe’s picture

Thanks rusty! I was headed there but just couldn't quite remember what kind of variable or where to find it. It's working now!