Domanda

Sto cercando di eliminare un utente quando un gateway di pagamento richiede, ho il seguente codice:

(Codice modificato per mostrare la funzione completa che comunica con il gateway di pagamento, l'Eco dà la risposta al gateway di pagamento che le uscite sono perché viene utilizzata nel codice di esempio dei gateway di pagamento.)

function handle_gateway_return() {
    $GWPass = get_option( $this->gateway . "_gateway_gwpass" );

    if ($_GET["GWPass"] != $GWPass ) {
        header("HTTP/1.0 401 Unauthorized");
        echo "<h1>Gateway 1.1</h1><h3>Authentication failed.</h3>";
        exit;
    }

    //==================================================
    // Action: user.add
    //==================================================

    if ($_GET["Action"] == "user.add") {
        // Load variables
        $ZFirstName     = trim($_GET['FIRSTNAME']);
        $ZLastName      = trim($_GET['LASTNAME']);
        $ZFullName      = $ZFirstName." ".$ZLastName;
        $ZUserName      = trim($_GET['username']);
        $ZEmail         = trim($_GET['EMAIL']);
        $ZPassword      = trim($_GET['password']); 
        $ZPassword      = md5($ZPassword); //md5

    if ( username_exists( $ZUserName ) ) {
        echo "OK|User Added!";
        exit;   
        }

    if ( !username_exists( $ZUserName ) ) {
        wp_create_user( $ZUserName, $ZPassword, $ZEmail );
        echo "OK|User Added!";
        exit;
        }

    }

    //==================================================
    // Action: user.delete
    //==================================================

    else if ($_GET["Action"] == "user.delete") {
        $ZUserName = trim($_GET['username']);

    // Grab user_id
    $user = get_user_by('login', $ZUserName);

    if (!$user) {
        echo 'USER_DOES_NOT_EXIST';
        exit;
        }

    $url = network_site_url('/wp-admin/includes/ms.php');
    if ($user) {
        include($url);
        wpmu_delete_user($user->ID);
        echo "OK|User Deleted!";
        exit;
        }

    } else { 
        echo "UNKNOWN_ACTION|UNKNOWN_ACTION";
        exit;
    }   

}

Tuttavia l'utente non viene eliminato! Che cosa sto facendo di sbagliato?

Grazie in anticipo per il vostro aiuto!

EDIT: questo sta accadendo all'interno di un file aggiuntivo gateway di pagamento utilizzato nel plug -in abbonamento WPMudevs. Nel file addon ho una funzione che si occupa del ritorno del gateway e la creazione dell'utente funziona bene usando wp_create_user e sì, non è stato necessario includere lì. Ho aggiunto l'inclusione qui semplicemente perché l'ho visto menzionato da qualche parte e ho pensato che avrei provato come senza l'inclusione non funzionava neanche (ma non pensavo che fosse necessario).

Nessuna soluzione corretta

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a wordpress.stackexchange
scroll top