Viewing 2 reply threads
  • Author
    Posts
    • #7715
      Stephen
      Participant

      Hi I would like to add a simple contact form on each post page, that will have the author email in the To: field and the site admin email in the From field. I am not quite sure what approach to take with Piklist to define my form inside a metabox. Should this be an HTML field? Some combo of field types? Where should the form logic live? Just looking for some general direction here…Thanks!

    • #7730
      Steve
      Keymaster

      @ssuess– I would create a metabox with all the fields you want:

      -author email: gets pulled in automatically
      -message

      Then in your regular plugin file or themes functions.php try something like this:

      function email_on_post_status($post_id)
      {
      	global $post, $typenow;
      
      	
      	$post_status = get_post_status($post_id);
      
      	//verify post is not a revision
      	if (!wp_is_post_revision($post_id) && !wp_is_post_autosave($post_id))
      	{
                //use get_post_meta to get author email and message. Pass to wp_mail
      
      	 wp_mail($params);
      	}
      }
      add_action('save_post', 'email_on_post_status', 1, 2);
      add_action('transition_post_status', 'email_on_post_status', 10, 3);
    • #7757
      Stephen
      Participant

      Thanks I will give it a go!

Viewing 2 reply threads
  • You must be logged in to reply to this topic.