• 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? <[email protected]>’;
    //$headers[] = ‘Cc: Tasso P. <[email protected]>’;
    $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 [email protected]“);
    }
    }
    }
    }

    https://www.ads-software.com/extend/plugins/allow-php-in-posts-and-pages/

  • The topic ‘php snippet 2 times execution but not in my code’ is closed to new replies.