Created
July 16, 2025 23:36
-
-
Save seanconklin/31bb359c567943226dec0e0158af8b51 to your computer and use it in GitHub Desktop.
Connect Contact Form 7 form with Benchmark Email contact list
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
Show hidden characters
| {"generator":"Code Snippets v2.14.0","date_created":"2020-03-19 17:43","snippets":[{"name":"Connect Contact Form 7 form with Benchmark Email contact list","desc":"Connects a Contact Form 7 form with a Benchmark Email contact list.","scope":"front-end","code":"\/\/ Hook Into CF7 Submissions\nadd_action( 'wpcf7_submit', function( $instance, $result ) {\n\n\t\/\/ Settings\n\t$cf7_form_id = 56;\n\t$benchmark_list_id = 15838208;\n\n\t\/\/ Limit To Form\n\tif( $instance->id !== $cf7_form_id ) { return; }\n\n\t\/\/ Ensure Benchmark Email Lite Is Active\n\tif( ! class_exists( 'wpbme_api' ) ) { return; }\n\n\t\/\/ Build Body\n\t$body = [\n\t\t'Data' => [\n\n\t\t\t\/\/ Main Fields\n\t\t\t'Email' => isset( $_POST['your-email'] ) ? $_POST['your-email'] : '',\n\t\t\t'FirstName' => isset( $_POST['first-name'] ) ? $_POST['first-name'] : '',\n\t\t\t'LastName' => isset( $_POST['last-name'] ) ? $_POST['last-name'] : '',\n\n\t\t\t\/\/ Contact Fields\n\t\t\t'Field1' => isset( $_POST['address'] ) ? $_POST['address'] : '',\n\t\t\t'Field2' => isset( $_POST['city'] ) ? $_POST['city'] : '',\n\t\t\t'Field3' => isset( $_POST['state'] ) ? $_POST['state'] : '',\n\t\t\t'Field4' => isset( $_POST['zipcode'] ) ? $_POST['zipcode'] : '',\n\t\t\t'Field5' => isset( $_POST['country'] ) ? $_POST['country'] : '',\n\t\t\t'Field6' => isset( $_POST['phone'] ) ? $_POST['phone'] : '',\n\t\t\t'Field9' => isset( $_POST['company'] ) ? $_POST['company'] : '',\n\t\t\t'Field18' => isset( $_POST['website'] ) ? $_POST['website'] : '',\n\n\t\t\t\/\/ Required Fields\n\t\t\t'EmailPerm' => 1,\n\t\t\t'Field19' => current_time( 'm\/d\/Y' ),\n\t\t\t'IPAddress' => function() {\n\t\t\t\tif( isset( $_SERVER[ 'HTTP_CLIENT_IP' ] ) )\n\t\t\t\t\treturn $_SERVER[ 'HTTP_CLIENT_IP' ];\n\t\t\t\tif( isset( $_SERVER[ 'HTTP_X_FORWARDED_FOR' ] ) )\n\t\t\t\t\treturn $_SERVER[ 'HTTP_X_FORWARDED_FOR' ];\n\t\t\t\tif( isset( $_SERVER[ 'HTTP_X_FORWARDED' ] ) )\n\t\t\t\t\treturn $_SERVER[ 'HTTP_X_FORWARDED' ];\n\t\t\t\tif( isset( $_SERVER[ 'HTTP_FORWARDED_FOR' ] ) )\n\t\t\t\t\treturn $_SERVER[ 'HTTP_FORWARDED_FOR' ];\n\t\t\t\tif( isset( $_SERVER[ 'HTTP_FORWARDED' ] ) )\n\t\t\t\t\treturn $_SERVER[ 'HTTP_FORWARDED' ];\n\t\t\t\tif( isset( $_SERVER[ 'REMOTE_ADDR' ] ) )\n\t\t\t\t\treturn $_SERVER[ 'REMOTE_ADDR' ];\n\t\t\t}\n\t\t],\n\t];\n\n\t\/\/ Add New Contact\n\t$uri = 'Contact\/' . $benchmark_list_id . '\/ContactDetails';\n\t$response = wpbme_api::benchmark_query( $uri, 'POST', $body );\n\n}, 10, 2 );","priority":"10"}]} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment