Skip to content

Instantly share code, notes, and snippets.

@andrewlimaza
Last active April 24, 2025 06:21
Show Gist options
  • Save andrewlimaza/d99d16df545bd7a5e699c94da43753fc to your computer and use it in GitHub Desktop.
Save andrewlimaza/d99d16df545bd7a5e699c94da43753fc to your computer and use it in GitHub Desktop.
Force First and Last Name as Display Name with Paid Memberships Pro Edit Member
<?php
/**
* Enable functionality for the Edit Member Panel when saving user info.
* Add this code to your site, follow this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
**/
function my_custom_ffl_fix_user_display_name() {
// Make sure Force First and Last Name is installed.
if ( ! function_exists( 'ffl_fix_user_display_name' ) ) {
return;
}
// Update on specific panel update.
$pmpro_page = empty( $_REQUEST['page'] ) ? '' : sanitize_text_field( $_REQUEST['page'] );
if ( $pmpro_page !== 'pmpro-member' ) {
return;
}
// Get the user ID from the request.
$user_id = empty( $_REQUEST['user_id'] ) ? 0 : intval( $_REQUEST['user_id'] );
if ( ! $user_id ) {
return;
}
// Generate the display name.
ffl_fix_user_display_name( $user_id );
}
add_action( 'admin_init', 'my_custom_ffl_fix_user_display_name', 99 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment