membership plugin show avatar current user

hi IT-team,

I think I have asked this before is there a easy way to show the current_user upload image?

like a avatar.

Thnx Maurice

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

Dropmonkey.nl

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