Skip to content

Instantly share code, notes, and snippets.

@slaFFik
Last active August 29, 2017 09:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save slaFFik/812cb87a717aa2327baaa157ea415e34 to your computer and use it in GitHub Desktop.
Save slaFFik/812cb87a717aa2327baaa157ea415e34 to your computer and use it in GitHub Desktop.
WPForms: Split the first Name field to display only First Name in notification text
<?php
add_filter( 'wpforms_process_smart_tags', function ( $message, $form_data, $fields = '', $entry_id = 0 ) {
// CHANGE THIS FORM ID TO YOURS:
if ( 157 != $form_data['id'] ) {
return $message;
}
// So we are not submitting the form.
if ( empty( $entry_id ) ) {
return $message;
}
// IN THE HOPE, THAT "NAME" FIELD HAS THE ID=0:
$message_updated = preg_replace( '~{field_id="0"}~', $fields[0]['first'], $message, 1 );
if ( is_null( $message_updated ) ) {
return $message;
}
return $message_updated;
}, ~PHP_INT_MAX, 4 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment