Forked from strangerstudios/my_init_email_as_username.php
Last active
April 25, 2017 16:48
-
-
Save greathmaster/de38b8ed4880711bce787e6e030feeb0 to your computer and use it in GitHub Desktop.
Create a random username with PMPro checkout. You'll also have to hide the username fields at checkout using CSS or a custom checkout page template.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function my_init_email_as_username() | |
{ | |
//check for level as well to make sure we're on checkout page | |
if(empty($_REQUEST['level'])) | |
return; | |
$random_username = pmpro_getDiscountCode(); | |
if(!empty($_REQUEST['bemail'])) | |
$_REQUEST['username'] = $random_username; | |
if(!empty($_POST['bemail'])) | |
$_POST['username'] = $random_username; | |
if(!empty($_GET['bemail'])) | |
$_GET['username'] = $random_username; | |
} | |
add_action('init', 'my_init_email_as_username'); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment