- This topic has 1 reply, 2 voices, and was last updated 10 years ago by .
Viewing 2 posts - 1 through 2 (of 2 total)
Viewing 2 posts - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.
Support site for Tips and Tricks HQ premium products
by
Tips and Tricks HQ Support Portal › Forums › WP eMember › WP eMember Tweaks › eMember – Retrieve member data without being logged in as member?
Tagged: custom field value
Hi,
For a check, based on a custom field value, I use the following code:
$emember_auth = Emember_Auth::getInstance();
$verification_id = $emember_auth->getUserInfo('Verification_ID');
if (!empty($_GET['cid']) && $_GET['cid'] == $verification_id) {
//Display post's comment form.
}
It works, but then I realized it only works with logged in members. While it should work for non-logged in users as well.
Each member also has a custom eMember field, containing a unique WP post ID. So I could retrieve the Verification ID, based on the ID of the post a user is currently viewing/reading. Something like this:
$emember_auth = Emember_Auth::getInstance(POST_ID);
$verification_id = $emember_auth->getUserInfo('Verification_ID');
if (!empty($_GET['cid']) && $_GET['cid'] == $verification_id) {
//Display post's comment form.
}
But there’s a problem: getInstance()
doesn’t take any arguments (e.g. current post’s ID).
Does someone know how to retrieve specific custom field values, even when there’s no logged in user? Do I have to write a SQL query for that or can I use an already existing eMember function?
Thanks in advance.
Best,
Ralph
You can call a function to retrieve data of a member (given you know the member ID).
Here is an example snippet of code that will retrieve the email address of the member whose ID is 2:
$user_email = wp_emember_get_user_details_by_id('email', '2');
There are also shortcodes for this. See explanation in the following post: