Subject:*
<
Name/Email:*
<
Message Icon:*
<
Select*
<
Message:*
<



Click the Preview to see the content in action.
Options:*
<
Confirmation Code*
<
1 + 9 = ?  
Input the result from the expression
Maximum attempts you can try: 10
*
<
     

Re: display user avatar in template
by gregorybr on 2011/2/6 3:32:02

Hello
I am trying to create a custom block. I want this block to include viewpmsg.php link when I am on my own profile. When I visit someone's else profile, I want to have Send the message button instead of this link.

I tried to add this code, but it didn't help.
le="color: #000000"><?php <{if $user_ownpage && $xoops_isuser == true}> <a href="<{xoAppUrl viewpmsg.php}>">View your messages</a> <{else}> <input type="button" onclick="javascript:openWithSelfMain('<{$xoops_url}>/pmlite.php?send2=1&amp;to_userid=<{$user_uid}>', 'pmlite', 450, 380);" /> <{/if}>
Re: display user avatar in template
by Danielw42 on 2010/8/6 3:18:12

You are always correct. Thanks again trabis.
Re: display user avatar in template
by trabis on 2010/8/5 22:48:18

Quote:

Danielw42 wrote:
Trabis, one more thing. How to add display name, user location...to this block? What about displaying extra fields created in user profile module?


Just need to add an extra line:
le="color: #000000"><?php <{php}> global $xoopsUser; $uid = isset($_GET['uid']) ? intval($_GET['uid']) : -1; $mHandler = xoops_getHandler('member'); $user = $mHandler->getUser($uid); if (!is_object($user) && is_object($xoopsUser)) { $user =& $xoopsUser; } if (is_object($user)) { $GLOBALS['xoopsTpl']->assign('user', $user->getValues()); $uavatar = $user->getVar('user_avatar'); if (file_exists(XOOPS_ROOT_PATH.'/uploads/'.$uavatar) && $uavatar != 'blank.gif') { $GLOBALS['xoopsTpl']->assign('uavatar', XOOPS_URL.'/uploads/'.$uavatar); }else{ $GLOBALS['xoopsTpl']->assign('uavatar', XOOPS_URL.'/uploads/noavatar.jpg'); } } <{/php}>


Then you can get any user data from the $user array
le="color: #000000"><?php <{$user.uname}> <{$user.email}>


Hum, from profile it needs to be done in other way, there should be a thread about it somewhere.
Re: display user avatar in template
by ghia on 2010/8/5 21:43:09

Disable caching for the block.
Re: display user avatar in template
by Danielw42 on 2010/8/5 21:38:03

Thanks for your reply noo-b.
I know how to do this. I am asking how to display display name, user from.... in a block ( not in a template).
If I insert $xoopsUser->getVar('uname'); , my name is both displayed on my profile and someone else's profile.

Who's Online

229 user(s) are online (165 user(s) are browsing Support Forums)


Members: 0


Guests: 229


more...

Donat-O-Meter

Stats
Goal: $15.00
Due Date: Jul 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $15.00
Make donations with PayPal!

Latest GitHub Commits