Mallar Defaultmallar som kan vara bra att använda om det skulle försvinna från dev Mail back <?php function j_mail() { $message = strip_tags(trim($_POST["message"])); if(strstr($message, '://')) { sleep(2); wp_die('', 200); return; } $email = filter_var(trim($_POST["email"]), FILTER_SANITIZE_EMAIL); $name = strip_tags(trim($_POST["name"])); $phone = strip_tags($_POST['phone']); if(!filter_var($email, FILTER_VALIDATE_EMAIL) || empty($message) || empty($name) || empty($phone)) { wp_die('', 400); return; } $body = "Name: $name<br>"; $body .= "Number: $phone<br>"; $body .= "Email: $email<br>"; $body .= "Message: $message<br>"; $to = '[email protected]'; $subject = "Form: dev.jenkler.com - $email"; $headers[] = "Content-Type: text/html; charset=UTF-8"; $headers[] = "Reply-To: $name <$email>"; if(wp_mail($to, $subject, $body, $headers)) wp_die('', 200); else wp_die('', 400); } add_action('admin_post_mail', 'j_mail'); add_action('admin_post_nopriv_mail', 'j_mail'); ?> Mail front <h2>Kontakta oss gärna genom att fylla i uppgifterna</h2> <form action="/wp-admin/admin-post.php" id="ajax-contact" method="post"> <input type="hidden" name="action" value="mail"> <div class="form-group"> <label for="name">Namn</label> <input type="name" name="name" class="form-control" id="name" placeholder="Vad är ditt namn?" required=""> </div> <div class="form-group"> <label for="phone">Nummer</label> <input type="name" name="phone" class="form-control" id="phone" placeholder="Vilket telefonnummer kan vi nå dig på?" required=""> </div> <div class="form-group"> <label for="email">Email</label> <input type="email" name="email" class="form-control" id="email" placeholder="Vad har du för e-postadress?" required=""> </div> <div class="form-group"> <label>Meddelande</label> <textarea class="form-control" name="message" placeholder="Beskriv kort vad behöver du hjälp med? Notera att meddelanden som innehåller länkar kommer automatiskt att raderas." rows="3" required=""></textarea> </div> <input type="submit" class="btn btn-primary" value="Skicka"> </form> <br> <h4> <div id="form-error" style="display: none;"> Någonting gick fel, maila gärna manuellt till adressen i foten på sidan. </div> <div id="form-ok" style="display: none;"> Tack för ditt meddelande! Jag återkommer så snart jag kan. </div> </h4> <script> var form = jQuery('#ajax-contact'); var formMessages = jQuery('#form-messages'); jQuery(form).submit(function(event) { event.preventDefault(); var formData = jQuery(form).serialize(); jQuery.ajax({ type: 'POST', url: jQuery(form).attr('action'), data: formData }).done(function(response) { jQuery("#form-error").hide(); jQuery("#form-ok").show(); jQuery(form).remove(); }).fail(function(data) { jQuery("#form-error").show(); jQuery("#form-ok").hide(); }); }); </script> global-functions function j_is_path($match = '') { global $j_path; if($match == '') return $j_path.'/'; else return strtolower($match) == $j_path ? true : false; } function j_textfields($atts, $content) { global $j_page_id; return get_post_meta($j_page_id, $content, true); } $j_path = strtolower(trim(current(explode('?', $_SERVER['REQUEST_URI'], 2)), '/')); if(!is_admin()) { if(j_is_path() == '/') $j_page_id = get_option('page_on_front'); else { $j_page_id = get_page_by_path(j_is_path()); $j_page_id = isset($j_page_id->ID) ? $j_page_id->ID : 0; } add_shortcode('cf','j_textfields'); wp_enqueue_script('jquery'); //wp_enqueue_style('jenkler', get_template_directory_uri().'/assets/custom.css'); wp_enqueue_style('dev', 'https://files.jenkler.com/_README/tmp/tmp/mastercoach.css?'.rand()); } global-header <meta charset="<?php bloginfo('charset')?>" /> <?php if(get_bloginfo('description') != '') { echo '<meta name="description" content="'.get_bloginfo('description').'">'; }?> <meta name="author" content="Jenkler IT AB"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <title><?php wp_title()?></title> global-map if(!is_admin()) { function j_global_map_home() { get_header(); echo do_shortcode('[wbcr_snippet id="2722"]'); get_footer(); } function j_global_map_index() { get_header(); echo do_shortcode('[wbcr_snippet id="2718"]'); get_footer(); } }