Tips and Tricks HQ Support Portal › Forums › WP eMember › Best method to get and set eMember member custom fields?
Tagged: get member data, set member data, user integration
- This topic has 8 replies, 4 voices, and was last updated 1 week ago by
admin.
-
AuthorPosts
-
January 8, 2014 at 7:09 pm #10377
mskalla
MemberI am working on a project in which uses of one role ‘manage’ users of another role, and as such need to be able to view and edit other users’ data. This project is also using the eMember plugin with WP integration enabled (creating a member creates a WP user account, etc). Some user data fields are part of the WP user account, some are supplied by WP user metadata, some are part of the emember account, and some are from the emember plugin’s ability to create custom fields in the emember signup form. I can get WP user data and metadata, but how do I retrieve emember member data and metadata using a WP user ID? I need to be able to set the data as well as retrieve it. Are there any helper methods to handle any of the following tasks?
- get an emember member ID from a WP user ID (not just the current logged in user, but any user by ID)
- get emember data (stored in the wp_eMember_members_tbl database table)
- set emember data (stored in the wp_eMember_members_tbl database table)
- get emember metadata (stored in the wp_members_meta_tbl database table)
- set emember metadata (stored in the wp_members_meta_tbl database table)
Thanks for any help.
January 9, 2014 at 10:49 pm #60201admin
KeymasterYeah, some of those should be doable via some helper functions and shortcodes. Check this post:
How to Retrieve and Show Specific Details of the Logged-in Member
We also have an API for creating member accounts from your own script:
January 10, 2014 at 11:53 am #60202mskalla
MemberI had looked through that page prior to posting (as well as here:
and here:
and here:
How to Retrieve and Show Specific Details of the Logged-in Member
None of these answer my questions.
Again, I need to get and set member details, such as the address, city, state, zip, and phone number, (all of which are in the eMember signup form and do not seem to be changeable in any way after the user has submitted that form) using the member’s WP user ID, not their member ID. I do not only need to do this for the currently logged in user (allow the current user to view and edit their own membership data), but I need to allow users to be able to do this for other users as well, so being able to perform these operations on just the currently logged in user is not what I need. Finally, none of these above pages have anything at all about setting any of these values, even for the current user.
Thanks again for any further assistance.
January 11, 2014 at 2:08 am #60203admin
KeymasterI see what you mean. We don’t have any option for what you asked.
January 14, 2014 at 6:33 pm #60204mskalla
MemberOk, thanks, that is what I needed to know!
February 21, 2025 at 6:18 am #85139jubel
ParticipantRetrieving Custom Fields is easy for me, with methods, which emember brings with it self. Following shortcode I use to retrieve standard and custom fields:
add_shortcode(‘user_prop’, function() {
$emember_auth = Emember_Auth::getInstance();
$user_id = $emember_auth->getUserInfo(‘member_id’);
if (!empty($user_id))
{
//User is logged in so add your conditional code here
$membership_level = $emember_auth->getUserInfo(‘membership_level’);
if($membership_level == 2)
{
$emember_auth = Emember_Auth::getInstance();
$username = $emember_auth->getUserInfo(‘user_name’);
echo (“Username of the logged in member: “.$username . “<br />\n”);
echo (“Mitgliedslevel: Abonnent” . “<br />\n”);
$member = emember_get_member_by_username ($username);
echo (“Member’s First Name: ” . $member->first_name . “<br />\n”); //Output the first name
echo (“Member’s Last Name: ” . $member->last_name . “<br />\n”); //Output the last name
$value = $emember_auth->getUserInfo(‘Kursleiter’);
echo (“Kursleiter: ” . $value . “<br />\n”); //Output a custom field ???
$value = $emember_auth->getUserInfo(‘Umfragenteilnehmer’);
echo (“Umfragenteilnehmer: ” . $value . “<br />\n”); //Output a custom field ???
}
else
{
echo “no Abonnent”;
}
}
});But changing to Form Builder (I hope I am not off topic here whith it) lets me not retrieve the custom field Kursleiter.
How I have to do this?February 21, 2025 at 10:15 pm #85140admin
KeymasterHere is an example code showing how you can access the custom fields of Form builder addon.
$member_id = "123"; $field_key = 'kursleiter'; $custom_value = wp_emember_get_user_details_by_id($field_key, $member_id); echo "Value of Kursleiter: " . $custom_value ;
February 23, 2025 at 2:13 pm #85141jubel
ParticipantThank you! This was very helpful!
Is there something like:wp_emember_put/set/ or write_user_details_by_id($field_key, $member_id);
???
February 25, 2025 at 12:54 am #85143admin
KeymasterNo, the update should be done by using database query. We don’t advertise any feature like that so there is no method for it out of the box.
-
AuthorPosts
- You must be logged in to reply to this topic.