How can I show the Users Profile Picture on a Civicrm Form please (in joomla)?
Thanks a lot, Sri
How can I show the Users Profile Picture on a Civicrm Form please (in joomla)?
Thanks a lot, Sri
You can use an API to get the image URL for a contact. For eg -
$result = civicrm_api3('Contact', 'getsingle', [
'return' => ["image_URL"],
'id' => contact_id,
]);
And then copy the value returned by the above API and fed it to the source of image tag in simple HTML code:-
<p>
......
......
<img src = "$result['image_URL']" />
</p>
Just posting so that anyone having a similar question can benefit.
You can login to Civicirm and uder the Support Developer Menu Item look at Developer > API. Here you can generate your API code including any of the feilds you require. Following is the full PHP code I used to call the profile Display Name, Photograph, Job Title & Phone. Perhaps it is not the most optimized code but it works.. The last Print statements needs to be wrapped withing html tags for formatting. 2nd one is the image path so needs to wrapped within in a image tags src (can not post with html tags here)
(PHP starts) defined('_JEXEC') OR defined('_VALID_MOS') OR die( "Direct Access Is Not Allowed" ); $user = JFactory::getUser(); require_once JPATH_ROOT . '/administrator/components/com_civicrm/helpers/api.php'; CivicrmHelperApi::civiimport('api'); $email = $user->email; $details = civicrm_api3('Contact', 'getsingle', [ 'return' => ["display_name", "image_URL", "job_title", "phone"], 'email' => $email, ]); $profile = array(); $x=0; foreach ($details as $key => $value) { $profile[$x]= "$value"; $x=$x+1; } if ($profile[2]=="") { $profile[2]= "/templates/common/images/member-dash-default-photo.jpg"; } print_r( $profile[1]) echo $profile[2] print_r( $profile[3]) print_r( $profile[7]) print_r( $profile[9]) (PHP ends)