i tried to figure out, how to get just the username without linking to the profile. no success.

what i want, is to display a "Give Userpoints" link

Something like that <a href="user2userpoints/$USERS_PROFILE_NAME">Give Userpoints</a>

Michelle, may you tell me what to add in author_pane.module? May it be that the link disappears, when you are watching your own profile?

thank you!

Comments

Michelle’s picture

Status: Active » Fixed

This is untested but something like:

<?php
global $user;
if ($user->uid != $account->uid): ?>
<a href="user2userpoints/<?php print $account->name ?>">Give Userpoints</a>
<?php endif; ?>

Michelle

Witch’s picture

Great Michelle, i just had to add a slash

<a href="/user2userpoints/<?php print $account->name ?>

it works fine. thank you!!!!

Michelle’s picture

Oh, yep. I didn't look at your URL that close.

Michelle

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

dmetzcher’s picture

I'm so happy that I found this issue. I'd like to post my code below in case others might find it useful. Since, on my site, Userpoints equal money, I needed to remove the Userpoints on the Author Pane (Michelle already answered that question here: #370046: Userpoints on the Author Pane). Replacing it with a link that allows the visiting user to give points to the user whose Author Pane is being viewed was the next step.

In author-pane.tpl.php, I replaced...

<?php /* Points */ ?>
<?php if (isset($userpoints_points)): ?>
  <div class="author-pane-line author-points">
    <span class="author-pane-label"><?php print t('!Points', userpoints_translation()); ?></span>: <?php print $userpoints_points; ?>
  </div>
<?php endif; ?>

with...

<?php /* Points */ ?>
<?php /* Removed the code that caused the number of Userpoints to be printed out on the Author Pane. Added the code below that allows Userpoints to be given via Author Pane. */ ?>
<?php
  global $user;
  if (($user->uid != $account->uid) && ($user->uid != 0)):
?>
<div class="author-pane-line"><a href="/user2userpoints/<?php print $account->name ?>">Give Userpoints</a></div>
<?php endif; ?>

The new code above will display a link to "Give Userpoints" on the Author Pane if the user is viewing any Author Pane other than their own.
Note that the Userpoints Contrib package is required and the user2userpoints module (part of the Userpoints Contrib package) must be enabled and working.

Michelle’s picture

You might also want to check that $user->uid != 0.

Michelle

dmetzcher’s picture

You might also want to check that $user->uid != 0.

Nice catch, Michelle. Thanks. I've edited comment #5 above to include the code to check for anonymous users. :)

I also added a class (author-pane-line) so that it can be styled along with the other line items in the Author Pane.

mr.j’s picture

Don't forget to check for permission too:

if ($user->uid != $account->uid && $user->uid != 0 && user_access(USER2USERPOINTS_PERM_SEND)) {