Zusätzliches Menü

Holen Sie sich MemberPress noch heute! Lassen Sie sich für die Inhalte, die Sie erstellen, bezahlen! MemberPress jetzt kaufen
  1. Startseite
  2. Wissensdatenbank
  3. Fortgeschrittene Themen
  4. Benutzerdefinierte Codes
  5. Kontoanpassungen
  6. Benachrichtigung senden, wenn Benutzer Kontodaten aktualisieren 
  1. Startseite
  2. Wissensdatenbank
  3. Fortgeschrittene Themen
  4. Kundenspezifische Lösungen
  5. Benachrichtigung senden, wenn Benutzer Kontodaten aktualisieren 

Benachrichtigung senden, wenn Benutzer Kontodaten aktualisieren 

MemberPress integrations allow you to synchronize membership-related data with 3rd-party plugins and platforms. On the other hand, when users update their account data, this change won’t be automatically synced through MemberPress integrations.

This workaround will instead allow you to monitor your members’ data changes and manually apply updates where needed. 

This document will provide you with the code snippet that will send notifications when users update their account data. It will also explain how to add the code to your website and modify it according to your needs.

User Account Data Update Notifications Workaround  

As mentioned, MemberPress integrations are triggered when membership-related Veranstaltungen happen on your website. 

Thus, for example, when a user subscribes to a membership, this event will trigger any integrations listening to this event. This could be any marketing integration you connected to the MemberPress plugin ( e.g. MailChimp) or Null-Code-Integration

Here, the user’s data will be automatically synced with connected 3rd-party plugins and platforms. This means the member’s data will be added to the mailing or campaign lists used with these 3rd-party solutions. 

On the contrary, all your members have their account data saved within their WordPress user profiles. Thus, when users update their account data (e.g. the email address), this will not trigger any MemberPress integration. Hence, your mailing and campaign lists will still use the user’s data collected on registration instead of the new data.

In addition, WordPress won’t notify your administrators when users update their profile data. 

The workaround in this document changes WordPress's functioning, allowing the admin to receive notifications when users modify their profile data. This email notification will be sent to the main admin email address you set for your website.

Applying the Workaround

This workaround contains two code snippets. One code snippet will send notifications when users change their default WordPress user profile data. The second code snippet will send notifications if users change their data on the MemberPress account page.

You can apply the workaround in two ways:

  • Adding the code snippet from the WPCode library (WPCode Pro is required for this)
  • Adding the code snippet manually.

Add Code Snippets Using WPCode Plugin

Adding code snippets with the WPCode plugin requires no coding knowledge.

Wenn Sie die WPCode Pro, you can easily import the following code snippets:

Here, you should first connect your website with the WPCode Library.

If you have the free version of the WPCode Plugin, you can manually add the PHP code snippets explained below.

Adding Code Snippets Manually

Die first code snippet will notify the administrator when users modify data in their WordPress user profile. 

function user_profile_update( $user_id ) {
  $site_url = get_bloginfo('wpurl');
  $user_info = get_userdata( $user_id );
  $user_name = $user_info->display_name; //Retrieves user's full name  $user_email = $user_info->user_email; //Retrieves user's e-mail address
  $subject = "Profile Updated: ".$site_url."";
  $message = "Profile of $user_name , $user_email has been updated!"; //Displays retrieved user data in the message
  wp_mail( get_bloginfo('admin_email'), $subject, $message);
}
add_action( 'profile_update', 'user_profile_update', 10, 2);

You can add the code snippet manually using the free WPCode plugin. Here, navigate to Dashboard > Code Snippets > Add Snippet, create a custom PHP snippet, and add the code.

Alternativ können Sie auch add the code to the functions.php file for your child theme.

The code above works when the default WordPress user profile is updated, but it doesn’t apply to the MemberPress-specific data. Thus, to trigger notifications also when users modify data through their MemberPress Account page, the second code snippet is needed:

function account_user_profile_update( $user ) {
$user_id = $user->ID;
$site_url = get_bloginfo('wpurl');
$user_info = get_userdata( $user_id );
$user_name = $user_info->display_name; //Retrieves user's full name
$user_email = $user_info->user_email; //Retrieves user's e-mail address
$subject = "Profile Updated: ".$site_url."";
$message = "Profile of $user_name , $user_email has been updated!"; //Displays retrieved user data in the message
wp_mail( get_bloginfo('admin_email'), $subject, $message);
}
add_action( 'mepr-event-member-account-updated', 'account_user_profile_update');

Modifying Code Snippets

Both code snippets have similar structures and can be modified in the same way. However, even if modifications are the same, you must add them to each code snippet separately. 

In the example code above, the following lines retrieve specific user data and create the arguments to display that data:

$user_name = $user_info->display_name;
$user_email = $user_info->user_email;

These arguments are added to the message within the code to display retrieved user data in the e-mail body:

$message = "Profile of $user_name , $user_email has been updated!"; 

Furthermore, following this logic, you can add other arguments and update the message you wish to receive.

In addition, the code can be modified to send this notification to a custom e-mail address. To do this, the code needs to be updated on the following line:

wp_mail( get_bloginfo('admin_email'), $subject, $message);

Here, you can replace the get_bloginfo(‘admin_email') part of the code with the custom email. For example, to use the admin@your-domain.com email address, the mentioned line of code should look like this:

wp_mail( 'admin@your-domain.com', $subject, $message);
War dieser Artikel hilfreich?

Verwandte Artikel

Computerfrau

Holen Sie sich MemberPress noch heute!

Lassen Sie sich für die von Ihnen erstellten Inhalte bezahlen.