Created
October 28, 2024 14:31
-
-
Save kimcoleman/12d32fef4cf13b9f375a9fbfd70c0538 to your computer and use it in GitHub Desktop.
Send the custom field "last_name" to Kit.
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 | |
function my_pmpro_kit_add_last_name_to_subscribe_fields( $subscribe_fields, $user_email ) { | |
// Get the user by email | |
$user = get_user_by( 'email', $user_email ); | |
// If the user is found, add the last name to the fields | |
if ( $user ) { | |
$last_name = $user->last_name; | |
if ( $last_name ) { | |
$subscribe_fields['last_name'] = $last_name; | |
} | |
} | |
return $subscribe_fields; | |
} | |
add_filter( 'pmpro_convertkit_subscribe_fields', 'my_pmpro_kit_add_last_name_to_subscribe_fields', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment