i have created a dropdown menu populated with a list of group members, i am trying to dislay the profile icon of a selected member. i know that i have to use elgg_view_profile_icon($entity, $size), but how exactly do i get the entity of the selected member?
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by RaĆ¼l Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.
- Matt Beckett@Beck24
Matt Beckett - 0 likes
- costakisc@costakisc
costakisc - 0 likes
- costakisc@costakisc
costakisc - 0 likes
- Mohammed Aqeel@m.aqeel
Mohammed Aqeel - 0 likes
- costakisc@costakisc
costakisc - 0 likes
- Mark@Zander1983
Mark - 0 likes
- Matt Beckett@Beck24
Matt Beckett - 0 likes
- costakisc@costakisc
costakisc - 0 likes
You must log in to post replies.how did you get the list of group members?
elgg_list_entities_from_metadata
what i want to do is something like this:
$num = (1);
$member = elgg_list_entities_from_metadata(array(
//'metadata_names' => 'icontime',
'types' => 'user',
'limit' => $num,
'full_view' => false,
'pagination' => false,
'list_type' => 'gallery',
'gallery_class' => 'elgg-gallery-users',
'size' => 'tiny',
));
echo elgg_view_module($title, $member)
but i want to pick who the user is
I didnt understand what exactly you are trying to do. But the code you have shared, won't return you the group members. It will just return your site users. If you want to get members of a group, you have to use elgg_list_entities_from_relationship() instead of listing from metadata.
yea, i realised that, but it works either way. thats some code i found, and its not quite what i want, but i think its close. i just want to be able to pick a user, say from a drop down or where ever and display his profile icon in a module
Use
$members = get_group_members($group_id);
Then create dropdown list from these members. The next part depends on what you want to do. After this choose from a dropdown, do you want ajax to display icon? Or will there be a page reload? If page reload, skip the action since u are not saving anything, and create the form yourself. Something like:
echo "<form action='member'>";
echo elgg_view('input/dropdown', $params);
echo "<input type='submit'>Submit</input>";
echo "</form>";
After submitting, the url will look like <site base>/member?member_id=6
then do:
$member = get_entity(get_input('member_guid'));
elgg_view_entity_icon($member, "medium");
depending on what information you have, you can use get_user_by_username(), get_user($id), or by metadata/relationship as you mentioned above.
If you're creating a form to select a user there is a specific user input view
echo elgg_view('input/userpicker');
it will send an array of selected user guids which you can get in your action by
$guids = get_input('members');
i think all this is going to help its just a matter of putting it together. Should have explained it better in the beginning, want to make a plugin "member of the week" with the drop down in the admin settings. but i think everything i need is posted above in a couple of different ways. thanks matt, mark and mohammed