Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kimcoleman/12d32fef4cf13b9f375a9fbfd70c0538 to your computer and use it in GitHub Desktop.
Save kimcoleman/12d32fef4cf13b9f375a9fbfd70c0538 to your computer and use it in GitHub Desktop.
Send the custom field "last_name" to Kit.
<?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