membership plugin show avatar current user

By gregThomas - January 2, 2014

Hi Maurice, 

The problem is that the current_user doesn't collect images uploaded against the account. But there is a way to get these images manually:

<?php
  
  // load viewer library
  $libraryPath = 'cmsAdmin/lib/viewer_functions.php';
  $dirsToCheck = array('/home/greg/www/','','../','../../','../../../');
  foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
  if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }
  if (!@$GLOBALS['WEBSITE_MEMBERSHIP_PLUGIN']) { die("You must activate the Website Membership plugin before you can access this page."); }

  if($CURRENT_USER){
    $userImages = mysql_select('uploads', "`recordNum` = '{$CURRENT_USER['num']}' AND `fieldName` = 'upload_image' AND `tableName` =  '".accountsTable($GLOBALS['WSM_ACCOUNTS_TABLE'])."'");
  }


?>
<?php if(@$userImages): ?>
  <?php foreach($userImages as $image): ?>
    <img src="<?php echo $SETTINGS['uploadUrl'].$image['urlPath']; ?>" alt="This is you!" />
  <?php endforeach; ?>
<?php endif; ?>

So the above code checks if a user is logged in, and if they are it collects the users images from the upload_image field from the uploads table. You might have to change the field name to the one your user image is stored in (I've highlighted the text you'd need to change in red). The users images would be stored in the variable $userImages. You can then display the users image by cycling through the $userImages array and displaying each ones content.

Let me know if this doesn't work for you, or if you have any questions.

Cheers!

Greg 

Greg Thomas







PHP Programmer - interactivetools.com

By Maurice - January 17, 2014

Hi Greg,

Thnx for the solution we got it working but we did another workaround.

the only thing that the content manager have to do is to make sure that the image name is the same as the username.

it works works great.

Maurice

-------------------------------------------

Dropmonkey.nl

By ross - January 20, 2014

Hi Maurice

Thanks for the update! Glad you got something working. There are variations that I can think of the concept of user avatars so let me know if you wanted to have a more in-depth discussion.

Thanks!

-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/