WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to know what is wrong with my if statement here:

function new_post_creation_email() {
    global $post;
    $postid = $post->ID;
    $problem_type = get_post_meta($postid, 'problem_type', true);
    $description = the_content();
    if ($problem_type = 'phones') {
        $to = '1st email here';
    elseif ($problem_type = 'computers') {
        $to = '2nd email here';
    else {
        $to = '3rd email here';
    $subject = "New Ticket in " . get_post_meta($postid, 'problem_type', true);
    $message = "A new ticket has been added.  Please login to view and print.";

    wp_mail($to, $subject, $message);

Emails are correct in actual code Currently, the message sends but the same email arrives multiple times in my 1st email address, not the correct one.

share|improve this question

This is problem with your PHP syntax, not WP. You are using assignment (=) where you should be using comparison (==).

So this:

if( $problem_type = 'phones' )

should really be this:

if( 'phones' == $problem_type )

And same for other condition.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.