Created
February 17, 2017 19:58
-
-
Save kjohnson/6c37c8430a4536fd04b1633526e5202a to your computer and use it in GitHub Desktop.
Add {all_fields_with_values} merge tag to Email Actions
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 | |
| //... | |
| add_filter( 'ninja_forms_action_email_message', 'kbj_nf_email__all_fields_with_values', 10, 3 ); | |
| function kbj_nf_email__all_fields_with_values( $message, $data, $action_settings ){ | |
| if( isset( $data[ 'fields' ] ) && ! empty( $data[ 'fields' ] ) ){ | |
| $table = '<table>'; | |
| foreach( $data[ 'fields' ] as $field ){ | |
| if( ! isset( $field[ 'value' ] ) || empty( $field[ 'value' ] ) ) continue; | |
| $label = ( isset( $field[ 'settings' ][ 'label' ] ) ) ? $field[ 'settings' ][ 'label' ] : ''; | |
| $table .= "<tr><td>{$label}:</td><td>{$field[ 'value' ]}</td></tr>"; | |
| } | |
| $table .= '</table>'; | |
| } else { | |
| $table = ''; | |
| } | |
| return str_replace( '{all_fields_with_values}', $table, $message ); | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See: https://github.com/NinjaFormsSnippets/nf-snippet-all-fields-with-values-email