WordPress.org

Ready to get started?Download WordPress

Forums

Allow PHP in Posts and Pages
php snippet 2 times execution but not in my code (1 post)

  1. Tasso Peperone
    Member
    Posted 10 months ago #

    i have the following code inside a snippet and the code is executed two times. any idea ?

    $My_ID_Buono = intval($_POST["id-buono"]);
    $My_Costo_in_Crediti = intval($_POST["costo-in-crediti"]);
    global $wpdb;
    $current_user = wp_get_current_user();
    $My_Card_Detail = $wpdb->get_row('SELECT * FROM custom_card WHERE attivata = 1 AND bloccata = 0 AND id_utente = ' . $current_user->ID . " LIMIT 1", ARRAY_A);
    if ($My_Card_Detail != null) {
    if($My_Card_Detail["crediti"] >= $My_Costo_in_Crediti) {
    //Leggi codice univoco dal db, Send Email Utente, Esercente, Scarica Crediti, Scarica numero Buoni rimasti, Aggiorna tabella di log dei download
    $wpdb->flush();
    $My_Buono_Code = $wpdb->get_row('SELECT * FROM custom_codice_buono_20 LIMIT 1', ARRAY_A);
    if ($My_Buono_Code != null) {
    //Cancello il codice dalla tabella
    $wpdb->query("DELETE FROM custom_codice_buono_20 WHERE id = '" . $My_Buono_Code["id"] . "'");
    $wpdb->flush();
    //recupero il buono
    $My_Buono_Post = get_post($My_ID_Buono,ARRAY_A);
    $My_Buono_Azienda = get_post($My_Buono_Post["post_parent"],OBJECT);
    // Send Email Utente ed Esercente
    $headers[] = 'From: VitalyCard® <info@vitalycard.it>';
    //$headers[] = 'Cc: Tasso P. <tasso.peperone@gmail.com>';
    $headers[]= "Content-type: text/html";
    $to = $current_user->user_email;
    $subject = "VitalyCard® - Nuovo Buono Spendibile Scaricato";
    $message = "some text";
    wp_mail( $to, $subject, $message, $headers );
    $wpdb->query("UPDATE custom_card SET crediti = crediti - " . $My_Costo_in_Crediti . " WHERE attivata = 1 AND bloccata = 0 AND id_utente = " . $current_user->ID);
    $wpdb->flush();
    } else {
    echo("Errore nella generazione del codice. Chiamare il numero verde per assistenza o scrivere una mail ad assistenza@vitalycard.it");
    }
    }
    }
    }

    http://wordpress.org/extend/plugins/allow-php-in-posts-and-pages/

Reply

You must log in to post.

About this Plugin

About this Topic

  • RSS feed for this topic
  • Started 10 months ago by Tasso Peperone
  • This topic is not resolved
  • WordPress version: 3.5.1