How to add additional fields for optin
-
I have looked through the source code for the plugin and have not been able to additional fields to the optin and then have the information entered into the fields sent to my email.
I have added the fields but the information entered into the additional fields does not get sent to my email once submitted.
I tried editing the fronted js file as well as the ajax and php frontend files all to no avail.
I’m a not experienced in ajax, or php, so I’m sure it’s something dumb I’m overlooking.
Here are the code snippets I have edited so far:
## class-holler-functions.php
<div style="position: absolute; left: -5000px;" aria-hidden="true"><input type="text" name="hwp_hp" tabindex="-1" value=""></div> <?php self::name_row( $id ); ?> <input type="text" name="fName" id="fName" class="hwp-fname-input" placeholder="<?php _e( 'First Name', 'holler-box' ); ?>" autocomplete="on" autocapitalize="off" /> <input type="text" id="lName" name="lName" class="hwp-lname-input <?php if( get_post_meta( $id, 'dont_show_name', 1 ) === '1' ) echo 'no-name'; ?>" placeholder="<?php _e( 'Last Name', 'holler-box' ); ?>" autocomplete="on" autocapitalize="off" /> <select id = "state" name="state" class="hwp-state-input"> <option value="" disabled selected hidden>Select State</option> .... all the states </select> <input type="email" name="email" class="hwp-email-input <?php if( get_post_meta( $id, 'dont_show_name', 1 ) === '1' ) echo 'no-name'; ?>" placeholder="<?php _e( 'Enter email', 'holler-box' ); ?>" autocomplete="on" autocapitalize="off" /> <button class="hwp-email-btn"><?php echo $btn_text; ?></button> <?php } }
## class-holler-ajax.php
public function hwp_send_email() { if (empty($_GET['nonce']) || !wp_verify_nonce($_GET['nonce'], 'holler-box')) { wp_send_json_error('Verification failed.'); } if (empty($_GET['id']) || empty($_GET['email'])) wp_send_json_error('Missing required field.'); $msg = $_GET['msg'] . "\n"; $email = $_GET['email']; $fName = ( !empty( $_GET['fName'] ) ? $_GET['fName'] : 'EMPTY' ); $lName = $_GET['lName']; $state = $_GET['state']; $name = ( !empty( $_GET['name'] ) ? $_GET['name'] : null ); $title = $_GET['title']; if (!empty($title)) $msg .= "\nForm: " . $title; $msg .= "\nEmail: " . $email; $msg .= "\nFirst: " . $fName; $msg .= "\nLast: " . $lName; $msg .= "\nState: " . $state; if (!empty($name)) $msg .= "\nName: " . $name;
## holler-frontend.js
public function hwp_send_email() { if (empty($_GET['nonce']) || !wp_verify_nonce($_GET['nonce'], 'holler-box')) { wp_send_json_error('Verification failed.'); } if (empty($_GET['id']) || empty($_GET['email'])) wp_send_json_error('Missing required field.'); $msg = $_GET['msg'] . "\n"; $email = $_GET['email']; $fName = ( !empty( $_GET['fName'] ) ? $_GET['fName'] : 'EMPTY' ); $lName = $_GET['lName']; $state = $_GET['state']; $name = ( !empty( $_GET['name'] ) ? $_GET['name'] : null ); $title = $_GET['title']; if (!empty($title)) $msg .= "\nForm: " . $title; $msg .= "\nEmail: " . $email; $msg .= "\nFirst: " . $fName; $msg .= "\nLast: " . $lName; $msg .= "\nState: " . $state; if (!empty($name)) $msg .= "\nName: " . $name;
…
// Send email along with chat message to server holler.sendMsg = function( email, name, fName, lName, state, msg, id, title ) { holler.showSpinner( id ); $.ajax({ method: "GET", url: window.hollerVars.ajaxurl, data: { email: email, fName: fName, lName: lName, state: state, name: name, id: id, msg: msg, action: 'hwp_send_email', nonce: window.hollerVars.hwpNonce, title: title } }) .done(function(msg) {
Please advise.
- The topic ‘How to add additional fields for optin’ is closed to new replies.