Events Made Easy › Forums › How do I … › accessing member details in php
- This topic has 6 replies, 2 voices, and was last updated 4 years, 6 months ago by Franky.
-
AuthorPosts
-
Thu 14 May 2020 at 21:28 #61200AnonymousInactive
Hi Franky,
I’m trying to make a kind of ‘my_account’ page and want to use member details. To see what’s available I first tried to see what’s in the arrays as in the Payment description filters example on the hooks and filters documentation page. I used that code recently and it worked fine. Now I’m trying the below code, but it seems the arrays are empty.
I prefer to do it in a shortcode to avoid code duplication on my page with all the eme if tags, but if another way is possible that would of course also be fine.
(btw: I was trying the code while logged in as a member with status pending).
function member_and_membership_details() { $member = eme_get_member($payment['member_id']); $membership = eme_get_membership($member['membership_id']); $person = eme_get_person($member['person_id']); $html = '<pre>'.print_r($member, true).print_r($membership, true).print_r($person, true); return $html; } add_shortcode('MEMBER_AND_MEMBERSHIP_DETAILS', 'member_and_membership_details');
Fri 15 May 2020 at 00:11 #61202FrankyKeymasterAdding a shortcode also implies calling the shortcode. It all depends on how you call it, using do_shortcode you need to pass the $payment array as a variable.
Fri 15 May 2020 at 00:18 #61204AnonymousInactiveOh bloody I need the $payment variable of course…
I use the shortcode on my page inside a Divi module, so there I can’t call do_shortcode. Of course Divi processes the entire page and does call do_shortcode. However that way I can’t get the $payment variable in. Would there be a way to get to the $payment variable by a call from within the function that processes my shortcode?
Fri 15 May 2020 at 00:20 #61205AnonymousInactiveIf the $payment variable is available at all at that time of course…else I would need something else to get access to the details of the member and membership 🙂
Fri 15 May 2020 at 00:28 #61206FrankyKeymasterThe $payment variable is only available in specific EME functions, it is not a global variable.
What is available is the wordpress logged in user id, and then you can get the linked EME person id and all the linked memberships too. See the calls eme_get_active_membershipids_by_wpid and eme_get_memberids_by_wpid.
However, it seems you’d need something like a [eme_mymemberships] shortcode (similar to [eme_mybookings]). That shortcode is yet to be written 🙂 I’ll see if I can cook up something. Edit: in fact that already exists (seems I forgot to document it), but it can use some improvement (no template yet).Fri 15 May 2020 at 00:35 #61207AnonymousInactiveThanks Franky!
I’ll have a look into this tomorrow…it’s getting late again.
Would be very great to see what you come up with, but no need to rush 😉
Fri 15 May 2020 at 00:44 #61208FrankyKeymasterThis should fix it: https://plugins.trac.wordpress.org/changeset/2305237
-
AuthorPosts
- The forum ‘How do I …’ is closed to new topics and replies.