Home / Admin / MemberPress: Manually Refresh Member Data
Duplicate Snippet

Embed Snippet on Your Site

MemberPress: Manually Refresh Member Data

This code snippet is designed to manually refresh all members' data on a WordPress site. After adding the snippet to the site's code, update the member data by adding this to the site's URL

/wp-admin/?update-member-data=true.

This will trigger the update process for all members' data. After running this, you should clear any site cache and check the Members page again to ensure the updates have taken effect

Change the Capability Requirement:

If you want to allow users with a different capability to run this update (not just administrators), modify the line:

current_user_can( 'administrator' )

For example, to allow editors to run the update, change it to:

current_user_can( 'editor' )

Code Preview
php
<?php
/**
 * Manually refresh all members' data.
 *
 * Once this snippet is added, visit /wp-admin/?update-member-data=true on your site to update all member data.
 * After running the update, clear any site cache and check the Members page again.
 */
function mepr_custom_update_all_member_data() {
  if( is_admin() && current_user_can( 'administrator' ) && isset( $_REQUEST['update-member-data'] ) ) {
    MeprUser::update_all_member_data();
    wp_die( 'All Member Data Updated' );
  }
}
add_action( 'admin_init', 'mepr_custom_update_all_member_data' );

Comments

Add a Comment