prefix . 'afm_list'; $charset_collate = $wpdb->get_charset_collate(); $sql = "CREATE TABLE $table_name ( id mediumint(9) NOT NULL AUTO_INCREMENT, fname varchar(55) DEFAULT '' NOT NULL, lname varchar(55) DEFAULT '' NOT NULL, phone varchar(15) DEFAULT '' NOT NULL, email varchar(55) DEFAULT '' NOT NULL, location varchar(55) DEFAULT '' NOT NULL, visit varchar(55) DEFAULT '' NOT NULL, comment text NOT NULL, callback_status varchar(10) DEFAULT 'No' NOT NULL, request_time datetime DEFAULT '0000-00-00 00:00:00' NOT NULL, response_time datetime DEFAULT '0000-00-00 00:00:00' NOT NULL, UNIQUE KEY id (id) ) $charset_collate;"; require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); dbDelta( $sql ); } register_activation_hook( __FILE__, 'afm_plugins_default_mail_settings' ); function afm_plugins_default_mail_settings(){ global $wpdb; if(get_option( 'afm_admin_mail_to_option' ) == ''){ update_option( 'afm_admin_mail_to_option', get_option( 'admin_email' ) ); } if(get_option( 'afm_admin_mail_subject' ) == ''){ update_option( 'afm_admin_mail_subject', 'Regarding appointment form submission' ); } if(get_option( 'afm_admin_mail_from_email' ) == ''){ update_option( 'afm_admin_mail_from_email', get_option( 'admin_email' ) ); } if(get_option( 'afm_admin_mail_from_name' ) == ''){ update_option( 'afm_admin_mail_from_name', 'Appointment' ); } //update_option( 'afm_admin_mail_to_bcc', $afm_admin_mail_to_bcc ); if(get_option( 'afm_admin_send_success_msg' ) == ''){ update_option( 'afm_admin_send_success_msg', "Thank you for booking an appointment with WP 4.2.2 Test, we will call you back to confirm a time and date within 48 hours." ); } if(get_option( 'afm_admin_send_err_msg' ) == ''){ update_option( 'afm_admin_send_err_msg', "An error found. Mail sending failed." ); } if(get_option( 'afm_admin_send_name_msg' ) == ''){ update_option( 'afm_admin_send_name_msg', get_bloginfo('name') ); } if(get_option( 'afm_admin_send_email_msg' ) == ''){ update_option( 'afm_admin_send_email_msg', get_option( 'admin_email' ) ); } if(get_option( 'afm_admin_send_subject_msg' ) == ''){ update_option( 'afm_admin_send_subject_msg', "Thank you for booking an appointment" ); } if(get_option( 'afm_invalid_captcha_err_msg' ) == ''){ update_option( "afm_invalid_captcha_err_msg", "Enter captcha is wrong." ); } if(get_option( 'afm_null_captcha_err_msg' ) == ''){ update_option( "afm_null_captcha_err_msg", "Captcha is required." ); } if(get_option( 'afm_null_fname_err_msg' ) == ''){ update_option( "afm_null_fname_err_msg", "First name is required." ); } if(get_option( 'afm_null_lname_err_msg' ) == ''){ update_option( "afm_null_lname_err_msg", "Last name is required." ); } if(get_option( 'afm_null_phone_err_msg' ) == ''){ update_option( "afm_null_phone_err_msg", "Phone number is required." ); } if(get_option( 'afm_valid_phone_err_msg' ) == ''){ update_option( "afm_valid_phone_err_msg", "Phone number is invalid." ); } if(get_option( 'afm_null_email_err_msg' ) == ''){ update_option( "afm_null_email_err_msg", "Email is required." ); } if(get_option( 'afm_valid_email_err_msg' ) == ''){ update_option( "afm_valid_email_err_msg", "Email is not valid." ); } if(get_option( 'afm_null_location_err_msg' ) == ''){ update_option( "afm_null_location_err_msg", "Location is required." ); } if(get_option( 'afm_null_visit_err_msg' ) == ''){ update_option( "afm_null_visit_err_msg", "Visit is required." ); } if(get_option( 'afm_null_comment_err_msg' ) == ''){ update_option( "afm_null_comment_err_msg", "Comment is required." ); } } function afm_insert_visitor_mail_data($fname, $lname, $phone, $email, $location, $visit, $comment) { global $wpdb; $table_name = $wpdb->prefix . 'afm_list'; $wpdb->insert( $table_name, array( 'request_time' => current_time( 'mysql' ), 'fname' => $fname, 'lname' => $lname, 'phone' => $phone, 'email' => $email, 'location' => $location, 'visit' => $visit, 'comment' => $comment ) ); } function afm_display_html_form() { ?>
' . get_option( "afm_null_fname_err_msg" ) . '
' . get_option( "afm_null_lname_err_msg" ) . '
' . get_option( "afm_null_phone_err_msg" ) . '
Please enter valid phone number.
' . get_option( "afm_null_email_err_msg" ) . '
' . get_option( "afm_valid_email_err_msg" ) . '
' . get_option( "afm_null_location_err_msg" ) . '
' . get_option( "afm_null_visit_err_msg" ) . '
' . get_option( "afm_null_captcha_err_msg" ) . '
' . get_option( "afm_invalid_captcha_err_msg" ) . '
Options saved
Options saved
| ID | First Name | Last Name | Phone | Location | Visit | Callback | Actions | |
First Name: $acffname
Surname: $acflname
Phone No: $acfphone
E-mail: $acfemail
Location: $acflocation
Type of Visit: $acfvisit
Comments: $acfcomment
" . get_option( 'afm_admin_send_success_msg') . "
' . get_option( 'afm_admin_send_success_msg') . '
'; echo '' . get_option( 'afm_admin_send_err_msg') . '
'; } } // Return the String die($results); } // creating Ajax call for WordPress add_action( 'wp_ajax_nopriv_ajaxcontact_send_mail', 'ajaxcontact_send_mail' ); add_action( 'wp_ajax_ajaxcontact_send_mail', 'ajaxcontact_send_mail' );
'; echo '
' . get_option( "afm_null_comment_err_msg" ) . '