Hi,
Does somebody know what is the best way to add a custom field to a user profile and then get the value in a custom view ?
I have added a custom field via the administration page (http://localhost/elgg/admin/appearance/profile_fields) but i don't know how I can retrieve the value of this field. (There is no specific id set in the administration page for each new fields ?)
I retrieve the current user with: $user = elgg_get_logged_in_user_entity();
Thanks for you help
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.
- iionly@iionly
iionly - 0 likes
- Arnaud@palarlap
Arnaud - 0 likes
- iionly@iionly
iionly - 0 likes
- Arnaud@palarlap
Arnaud - 0 likes
You must log in to post replies.I also don't think that the admin interface to add custom profile fields is of much use (if you want to do more than just display these fields and their values on profile pages). It seems the custom fields are addressed by id internally (which is of course not very intuitive and might cause trouble if you ever change the order of the fields).
Don't know how the plugin does it @Tom has linked. But there's the 'profile:fields', 'profile' plugin hook you can use. Just register a function to add a profile field / fields in the init funtion of your plugin:
And then add the my_custom_profile_fields_handler() function also to start.php of your plugin:
And then you should be able to get the values saved in a field for a user (e.g. the logged in user) with
Thanks, that works perfectly !
do you know if there is a specific hook to unregister default fields ?
Should work with the same plugin hook:
Thanks !