dashboard widget form not submit mails


I’m adding for the first time a wordpress dashboard widget. I’m creating a simple form to give the user the ability to send support request directly from wp dashboard. I’m not sure if all the code is working, during a test, I’ve noticed that the form will not submit the mail message. Can anyone help me?

function uptheme_support_dashboard_widgets()
    global $wp_meta_boxes;
    wp_add_dashboard_widget('custom_help_widget', 'Premium Ticket System', 'custom_dashboard_help');

  function custom_dashboard_help()
    $current_theme = wp_get_theme( 'uptheme-panel' );
      <p><?php _e('Hi! you are using the custom theme '. esc_html($current_theme) ); ?></p>
      <p><?php _e('Use the form to request support for your theme.'); ?></p>
      <form method="POST">
      <p><?php _e('Email'); ?></p>
        <input type="text" class="widefat" name="email" id="email" placeholder="" />
      <p><?php _e('Request type'); ?></p>
        <select name="support_ticket_type">
          <option value=""><?php _e('Support request'); ?></option>
          <option value=""><?php _e('Modification request'); ?></option>
      <p><?php _e('Message'); ?></p>
        <textarea class="widefat" name="support_message"></textarea>
        <input type="hidden" name="action" value="submit_support_ticket">
        <?php wp_nonce_field( 'submit_support_ticket', 'support_ticket_hash' ); ?>
        <button class="btn-primary" type="submit" class=""><?php _e('Invia'); ?></button>
      <small><?php _e('Theme powered by'); ?><a href="#"><?php _e('theme author'); ?></a></small>
  add_action('wp_dashboard_setup', 'uptheme_support_dashboard_widgets');

  function _submit_support_ticket()
    if( isset($_POST['support_ticket_hash']) || ! wp_verify_nonce( $_POST['support_ticket_hash'], 'submit_support_ticket' ) ){
      //echo '';
    $email = $_POST['email'];
    $subject = $_POST['support_ticket_type'];
    $message = $_POST['support_message'];
    $to = 'mymail@provider.com';
    $headers[] = "From: <$email>";
    wp_mail( $to, $subject, $message, $headers );
  add_action( 'admin_post_submit_support_ticket', '_submit_support_ticket' );
, , sialfa 4 years 2020-03-07T07:50:54-05:00 0 Answers 91 views 0

Leave an answer