send email PMPRO code generated randow password

I use this code to send credential to users in Paid membership pro plugin:

https://gist.github.com/strangerstudios/5331923

Read More

In checkout I use PayPal Express and pay by check;

I modified this code because I would send credentials only to PayPal users when getting the checkout. In my code it seems it doesn’t recognize the gateway PayPal.

function my_generate_passwords() {

    //Get primary gateway
    $setting_gateway = get_option("pmpro_gateway");

    if (!empty($_REQUEST['username']) && empty($_REQUEST['password']) && $setting_gateway == "paypalexpress") { //if paypalexpress

        $_REQUEST['password'] = pmpro_getDiscountCode() . pmpro_getDiscountCode(); //using two random discount codes if paypalexpress

        $_REQUEST['password2'] = $_REQUEST['password'];
    }

    // If pay by check ... I try to insert else to see if the system do the switch condition
    else {

        $_REQUEST['password'] = pmpro_getDiscountCode(); //using one random discount codes if paybycheck

        $_REQUEST['password2'] = $_REQUEST['password'];
    }
}

add_action("init", "my_generate_passwords");

Am I wrong?

Related posts