• Hello,

    Not sure if this is right but im putting the meta info into a variable like so:

    $type = get_post_meta($post->ID, ‘ptype’, true);

    This works fine and even when i echo out the right value is shown. However as soon as i try and compare this value it all falls to pieces. eg i did:

    if (($type ==’basic’) && ($mc >=3)) {
    $wpdb->query(“UPDATE wp_credit SET cred =cred-3 WHERE name='” . $current_user->user_login . “‘”);
    }

    just to rule out mc is greater than 3 so that shouldnt affect it. The query runs fine when i run it outside the if. As soon as i remove the $type == “basic” check the code runs fine. Also the meta data does exist. i even tried chnaging the value to an integer so that it will compare with the value. i also tried the identical === operator but no joy ??

    What i dont understand is $type does contain “basic” so why does it fail. Is there something im missing?

    Thank you for your time

    fl3x7

    p.s this is in a plugin file – as im attempting to create my first plugin ??

Viewing 1 replies (of 1 total)
  • Thread Starter fl3x7

    (@fl3x7)

    okay thats strange, as soon as i take the code out of the function and run it in one of my plugin php files it works perfectly.

    Yet as soon as i have it run with the publish_post hook it doesnt do anything, no error though. The function is run on the publish_post, just it doesnt do the database chnages.

    Any ideas?

    cheers

    fl3x7

Viewing 1 replies (of 1 total)
  • The topic ‘get_post_meta problem when using an operator’ is closed to new replies.