WordPress.org

Ready to get started?Download WordPress

Forums

contact form works in one theme, not in the other (1 post)

  1. do77
    Member
    Posted 1 year ago #

    Hi there,

    I hardcoded a contact form into my theme's sidebar and it works. Now I added the exact same code to another theme and it doesn't send the email. Any idea why?

    <?php global $current_user;
          get_currentuserinfo();
    ?>
    
    <?php
    //If the form is submitted
    if($_POST) {
    
    	$to = '### (Email deleted for purpose of posting)';
    	$subject = . $name . ' sent you a message!';
    	$message = $_POST['message'];
    
    	$name = $_POST['name'];
    	$from_email = $_POST['email'];
    	$headers = 'From: ' . $name . ' < ' . $from_email . ' >'; 
    
    	wp_mail( $to, $subject, $message, $headers );
    
    } ?>
    
    <form method="POST">
    
    <input type="hidden" name="name" id="name" value="<?php echo $current_user->display_name; ?>">
    <input type="hidden" name="email" id="email" value="<?php echo $current_user->user_email; ?>">
    <textarea name="message" id="message" rows='' cols='' placeholder="Your message..."></textarea>
    <input type="submit" name="submit" id="submit" value="Submit" />
    
    <div class="clear"></div>
    </form>

Topic Closed

This topic has been closed to new replies.

About this Topic