Forums

[resolved] Notify specific user based on Custom Field (3 posts)

  1. mrpritchett
    Member
    Posted 10 months ago #

    Hello! I am a moderate skill level WP user, and I am working on a template that works as a ticket system for an IT dept. Tickets (posts) are posted from the front end using a method similar to http://voodoopress.com/2011/03/review-of-posting-from-front-end-form/. That being said, I need a way to send an email to specific admin level users upon posting of tickets based on the value of a custom field. I can write the if statement for the custom field, but have no idea how to send the email through wordpress. Any ideas?

  2. mrpritchett
    Member
    Posted 10 months ago #

    This is what I have come up with so far, but I have yet to receive an email, although my form still posts.

    //EMAIL ADMIN BASED ON PROBLEM_TYPE
    function new_post_creation_email($pid) {
    $problem_type = get_post_meta($pid, 'problem_type', true);
    $description = 'post_content';
    if ($problem_type == 'phones') {
    $to = '____@_____.___';
    }
    elseif ($problem_type == 'computers') {
    $to = '____@_____.___';
    }
    else {
    $to = '____@_____.___';}
    $subject = "New Ticket in ' . echo get_post_meta($pid, 'problem_type', true) . ";
    $message = "A user profile has been updated\n\n";
    $message .= print_r($description,true);
    @wp_mail( $to, $subject, $message);
    }
    add_action('wp_insert_post','new_post_creation_email');
    ?>
  3. mrpritchett
    Member
    Posted 10 months ago #

    Fixed it! Ended up being this:
    `//EMAIL ADMIN BASED ON PROBLEM_TYPE
    function new_post_creation_email($pid) {
    $problem_type = get_post_meta($pid, 'problem_type', true);
    $description = the_content();
    if ($problem_type == 'phones') {
    $to = '_____@____.____';
    }
    elseif ($problem_type == 'computers') {
    $to = '_____@____.____';
    }
    else {
    $to = '_____@____.____';}
    $subject = "New Ticket in " . get_post_meta($pid, 'problem_type', true);
    $message = "A new ticket has been submitted at" . get_permalink( $pid);
    $message .= print_r($description,true);
    $headers = array(
    "From: TRBC HelpDesk <_____@____.____>",
    "Content-Type: text/html"
    );
    wp_mail( $to, $subject, $message);
    }
    add_action('wp_insert_post','new_post_creation_email');

Reply

You must log in to post.

About this Topic