Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save strangerstudios/5331923 to your computer and use it in GitHub Desktop.
Save strangerstudios/5331923 to your computer and use it in GitHub Desktop.
Auto generate passwords with Paid Memberships Pro
/*
Automatically generate password on checkout page.
Note: if you want to remove the entire user area and generate usernames and passwords, simply set the pmpro_skip_account_fields filter to return false.
Use the intstructions here (http://www.paidmembershipspro.com/documentation/advanced-techniques/templates/) to add a checkout page template with the password fields removed.
Uncheck the "Default WP notification email. (Recommended: Leave unchecked. Members will still get an email confirmation from PMPro after checkout.)" option in the PMPro Emails Settings tab.
*/
function my_generate_passwords()
{
if(!empty($_REQUEST['username']) && empty($_REQUEST['password']))
{
$_REQUEST['password'] = pmpro_getDiscountCode() . pmpro_getDiscountCode(); //using two random discount codes
$_REQUEST['password2'] = $_REQUEST['password'];
}
}
add_action("init", "my_generate_passwords");
@jacobshare
Copy link

If you setup automatic password generation, don't uncheck the "Default WP notification email" option in the PMPro Emails Settings tab, otherwise your new members won't receive their new passwords over email.

@JRyven
Copy link

JRyven commented Jul 14, 2015

What would be the correct way to set pmpro_skip_account_fields to false? The following didn't seem to work:

$skip_account_fields = apply_filters("pmpro_skip_account_fields", "false");

When the filter is set to false, is the Username that is automatically generated random? Or is the signup email used?

@amybill
Copy link

amybill commented Aug 4, 2015

Where am I supposed to place this code? in the checkout.php template or someplace else?

@davidjenner
Copy link

Please can you let me know how I can add this as I put it in the pmpro-customizations plugin but it doesn't reflect on the front-end?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment