Support

Home Forums Event Espresso Premium EE4 connect and integrate in Memberpress

EE4 connect and integrate in Memberpress

Posted: January 20, 2021 at 10:29 pm


markus.good@save.ch

January 20, 2021 at 10:29 pm

Hi there

We are using EE4. It is possible to register for an event with or without a member account. There is currently no special plugin for the user account, it is solved via WP-User. But now we would like to realise a professional member area with the plugin Memberpress. We choose this plugin, because on the following link it is written, that it is possible to connect EventEspresso with Memberpress. See https://eventespresso.com/product/eea-wp-user-integration/
…. You can connect Event Espresso’s WP User Integration to membership plugins like these: – S2member – Paid Memberships Pro – Members – Restrict Content Pro – Member Press …

Our goal is, that the logged in user (user with an account on our website) should be able to see or edit in the dashboard of Memberpress the following details:

A) My booked events (orders) = all registrations made by the user via EventEspresso

B) My user profile & addresses (participant address & billing address) = The user should be able to view and edit his personal data and addresses (participant address, billing address). These fields should be the same as EventEspresso input fields.

C) My invoices = The user should be able to view his receipts/invoices of the events.

How is it possible to realise it with EE4 to integrate/connect it with the plugin Memberpress? Because the information on your website is not sufficient. Thank you for your help.

Best regards


Tony

  • Support Staff

January 21, 2021 at 9:44 am

Hi there,

Whilst the WP User Integration add-on does allow membership plugins to ‘connect’ and work with it, that’s a little different from a full integration using the membership functions within those plugins (we don’t fully integrate with any membership plugins to allow you to have the choice of what you want to use).

Some of what you are asking to do can be done, but some will require custom development.

A) My booked events (orders) = all registrations made by the user via EventEspresso

This can be done using the [ESPRESSO_MY_EVENTS] shortcode from the add-on, see here:

https://eventespresso.com/wiki/wp-user-integration/#ee4-my-events

You’d add the above shortcode on the page you are using for membership details.

However, note that the above features show registrations made on events using the contact details that match the user account details, it does not show all registrations made by a specific account if they are changing contact details on the registration form.

B) My user profile & addresses (participant address & billing address) = The user should be able to view and edit his personal data and addresses (participant address, billing address). These fields should be the same as EventEspresso input fields.

This is the part that requires custom development, we don’t sync details with any membership plugins so whilst it’s possible to do, it will need custom development to pull the values from your membership plugin.

C) My invoices = The user should be able to view his receipts/invoices of the events.

The ESPRESSO_MY_EVENTS output mentioned above gives the user access to their invoices/receipts.


markus.good@save.ch

January 26, 2021 at 9:30 am

Hi Tony
Thank you for your answer. About the required custom development: Where have you got any documentations about EventEspresso’s API? Where could our developer find this code online and how we can get the data from the event registration to put it into MemberPress?

Thank you for your help.
Best regards
Markus


Tony

  • Support Staff

January 27, 2021 at 3:32 am

We have some documentation on our model system (which allows you to pull pretty much any data you would need) here:

https://github.com/eventespresso/event-espresso-core/tree/master/docs/G–Model-System

Where could our developer find this code online and how we can get the data from the event registration to put it into MemberPress?

We don’t have any code your developer can use for this as it’s not something we provide out of the box, they will need to write their own code which hooks into Event Espresso to update the account.

The function that updates the user profile is EED_WP_Users_SPCO::process_wpuser_for_attendee (within the WP User integration add-on)

If you look within that function you’ll find 2 actions you can use to update the user:

AHEE__EED_WP_Users_SPCO__process_wpuser_for_attendee__user_user_created

Is fired when a new user is generated and allows you to update more information that EE does by default.

do_action( 'AHEE__EED_WP_Users_SPCO__process_wpuser_for_attendee__user_user_updated', $user, $attendee, $registration );

Is fired every time that above function is called and allows you to update additional details.

If you take a look within EED_WP_Users_SPCO.module.php you’ll see how the EE4 Users Add-on does this with the current details.


markus.good@save.ch

February 1, 2021 at 1:38 am

This reply has been marked as private.


Tony

  • Support Staff

February 1, 2021 at 7:41 am

How is this data transferred? Is this data perhaps sent via a POST request?

Yes, it is a POST request sent via ajax and is handled by the Single Page CheckOut (SPCO for short).

If that’s the case, what’s the value name?

Sorry, but which value name?

If you are looking to hook into the attendee information processing, take a look at the AHEE__EE_Single_Page_Checkout__process_attendee_information__end hook (which is what the EED_WP_Users_SPCO::process_wpuser_for_attendee method I mentioned above uses).

You can pull all of the information you’ll need from that using our model system from above.


markus.good@save.ch

February 3, 2021 at 8:43 am

This reply has been marked as private.


Tony

  • Support Staff

February 4, 2021 at 5:53 am

Just to clarify, I didn’t say the fields weren’t included in the request, they are.

Are you looking to sync Event Espresso registration details TO Memberpress, or are you looking to pull the details FROM Memberpress into the EE registration questions on checkout? Or Both?

The reason I recommend you look into how process_wpuser_for_attendee works is it makes things easier for the developer as they can use the model system to pull all of the data they need but if you want to pull them directly from SPCO you’ll find an example of how to do that:

https://gist.github.com/Pebblo/0b3b28c9d0c52d5425fa167da1f1a622

However, due to the fact that people can set up their registrations to work in many different ways, there’s a fair bit more involved that way. Lines 12-16 show how I pull in the question groups related to the primary registrant from SPCO itself.

If you are using the WP User Integration add-on (which you will be if you are creating a ‘My Events’ section to output their registrations) then each time a registration is made then process_wpuser_for_attendee is called on the primary registrant anyway and then you can use the hooks within there (based on whether EE is creating the user or updating an existing user) to sync up the details with the user profile.

For example if you hook into AHEE__EED_WP_Users_SPCO__process_wpuser_for_attendee__user_user_updated

That hook is passed $user, $attendee, $registration.

$user being the WP_User account EEE found and updated.
$attendee being the EE_Attendee object linked to that user.
$registration being the specific EE_Registrtion object for this registration.

You can pull address details from the $attendee:

$attendee->address();
$attendee->address2();
$attendee->city();
$attendee->state_name();

For custom questions you can pull the answers from the registration:

$answers = $registration->answers();
foreach($answers as $answer) {
    //Do something with each answer object here.
}

Does that help?

If you haven’t read over the docs for the model system I highly recommend you do:

https://github.com/eventespresso/event-espresso-core/tree/master/docs/G–Model-System


markus.good@save.ch

February 18, 2021 at 8:19 am

This reply has been marked as private.


Tony

  • Support Staff

February 18, 2021 at 8:24 am

Hi Markus,

I’ve mentioned multiple hooks above so I’ll need to see the code they are using.

Whilst it is possible to include in the forum (you can host the file on your site and include a link on your reply) if you prefer to do this via email thats also fine.

You can use support[at]eventespresso.com, please include a reference to this thread within the opening email.


markus.good@save.ch

February 18, 2021 at 9:08 am

This reply has been marked as private.


Tony

  • Support Staff

February 18, 2021 at 11:44 am

Ok, the method I referenced above has 2 hooks and if you take a look at my reply HERE there is a reference to this hook:

AHEE__EED_WP_Users_SPCO__process_wpuser_for_attendee__user_user_created

Further on I gave an example of using this hook:

AHEE__EED_WP_Users_SPCO__process_wpuser_for_attendee__user_user_updated

The clue here is indeed in the name of the hook, the hook ending _user_created is fired when a user account is created by the add-on. The hook ending _user_updated is fired when a user account hasn’t been created but one has been updated (meaning the add-on found an existing user account and update that).

EE action hooks are in the format “AHEE__{FullyQualifiedClassName}__{MethodName}__{location within method}”, see HERE.

Your developer has chosen to use AHEE__EED_WP_Users_SPCO__process_wpuser_for_attendee__user_user_updated and they are correct in that hook does not fire when a user account is created, they need to hook into both actions if they want to do something for both situations.

The code for these actions can be found HERE.


markus.good@save.ch

February 25, 2021 at 3:37 am

This reply has been marked as private.


Tony

  • Support Staff

February 25, 2021 at 5:26 am

EventEspresso plugin doesn’t add errors to the Apache error logs.

That’s actually nothing to do with Event Espresso, it’s your server setup that controls what is logged and not Event Espresso. PHP errors would be logged in your error log, the content and location depend on how the server is set up.

So the question to you, is the following code snippet correct?

Whilst I don’t have a problem taking a look over a snippet it’s important to note that we don’t provide support for other peoples code, nor will we write that custom code for them.

The snippet is incorrect and is using actions without specifying the number of arguments to pass, meaning it uses the default of 1. That is likely why the above error is being thrown as it means the method does not have access to the $attendee or $registration variables declared within that method.

“This registration step could not be completed. Please refresh the page and try again.” is essentially a “catch all” for when EE hasn’t passed an error from within itself, but something failed. 99% of the time it means there is a fatal error being thrown by whatever PHP code is running at that time which halted the script.

Your developer needs to review how they are adding the actions (see HERE), its important to note values for priority and accepted_args when adding the action(s).

Do you have another way to see what errors are being thrown in EE4- AJAX?

EE4-AJAX requests are just another request to the server, they log errors in whatever way your server is set to do so.

There are many ways to log what is happening on the request but I’ll give you an example of one I use. In wp-config.php add define( 'WP_DEBUG_LOG', true );, I do it only when WP_DEBUG is set to true, like so:

define( 'WP_DEBUG', true );
if ( WP_DEBUG ) {
        @ini_set( 'display_errors', 0 );
        define( 'WP_DEBUG_LOG', true );
        define( 'WP_DEBUG_DISPLAY', false );
}

Which tells your server NOT to display the errors, but to log them, WordPress sets it’s own location when using just the above which is /wp-content/debug.log (note that’s a publicly accessible location).

Also, when you are on the checkout page, if you open up Chrome Dev Tools and watch the ‘Network’ tab, when you click the submit button you can view the request sent and see the headers. So if that request is throwing error 500, you’ll see it in the tab.

You must be logged in to reply to this support post. Sign In or Register for an Account

Support forum for Event Espresso 3 and Event Espresso 4.
Documentation for EE3 and EE4
Documentation for Event Espresso 3 Documentation for Event Espresso 4

Status: publish

Updated by  Tony 6 days, 18 hours ago ago

Topic Tags

Notifications

This topic is: not resolved
Do NOT follow this link or you will be banned from the site!