Skip to content

Instantly share code, notes, and snippets.

@travislima
Created August 21, 2018 09:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save travislima/4d599cc0b6169ef7ee7514442f289123 to your computer and use it in GitHub Desktop.
Save travislima/4d599cc0b6169ef7ee7514442f289123 to your computer and use it in GitHub Desktop.
Use the email address as username with PMPro checkout. You'll also have to hide the username fields at checkout using CSS or a custom checkout page template.
<?php // Do not copy this tag
// Use the email address as username with PMPro checkout. You'll also have to hide the username fields at checkout using CSS or a custom checkout page template.
// Paste the code below into a PMPro Customization Plugin: https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
function my_init_email_as_username()
{
//check for level as well to make sure we're on checkout page
if(empty($_REQUEST['level']))
return;
if(!empty($_REQUEST['bemail']))
$_REQUEST['username'] = $_REQUEST['bemail'];
if(!empty($_POST['bemail']))
$_POST['username'] = $_POST['bemail'];
if(!empty($_GET['bemail']))
$_GET['username'] = $_GET['bemail'];
}
add_action('init', 'my_init_email_as_username');
@MaryOJob
Copy link

MaryOJob commented Jan 10, 2020

See this gist on how to hide the username fields at checkout using CSS here: https://gist.github.com/travislima/e4b4618aa4141f911a3ba84bd24d9f67

@gausam
Copy link

gausam commented Aug 12, 2020

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