Last active
April 24, 2025 06:21
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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