Created
July 30, 2014 17:55
-
-
Save SeanChDavis/d79c23d5cc09da4c9bcb to your computer and use it in GitHub Desktop.
EDD Custom Register/Login on Checkout
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 | |
| /** | |
| * Checkout Registrition Form | |
| */ | |
| function custom_edd_get_login_fields() { | |
| global $edd_options; | |
| $color = isset( $edd_options[ 'checkout_color' ] ) ? $edd_options[ 'checkout_color' ] : 'gray'; | |
| $color = ( $color == 'inherit' ) ? '' : $color; | |
| $style = isset( $edd_options[ 'button_style' ] ) ? $edd_options[ 'button_style' ] : 'button'; | |
| $show_register_form = edd_get_option( 'show_register_form', 'none' ); | |
| ob_start(); ?> | |
| <fieldset id="edd_login_fields"> | |
| <?php if( $show_register_form == 'both' ) { ?> | |
| <p id="edd-new-account-wrap"> | |
| <?php _e( 'Need to create an account?', 'edd' ); ?> | |
| <a href="<?php echo remove_query_arg('login'); ?>" class="edd_checkout_register_login" data-action="checkout_register"> | |
| <?php _e( 'Register', 'edd' ); if(!edd_no_guest_checkout()) { echo ' ' . __( 'or checkout as a guest.', 'edd' ); } ?> | |
| </a> | |
| </p> | |
| <?php } ?> | |
| <?php do_action('edd_checkout_login_fields_before'); ?> | |
| <p id="edd-user-login-wrap"> | |
| <label class="edd-label" for="edd-username"><?php _e( 'Username', 'edd' ); ?></label> | |
| <input class="<?php if(edd_no_guest_checkout()) { echo 'required '; } ?>edd-input" type="text" name="edd_user_login" id="edd_user_login" value="" placeholder="<?php _e( 'Your username', 'edd' ); ?>"/> | |
| </p> | |
| <p id="edd-user-pass-wrap" class="edd_login_password"> | |
| <label class="edd-label" for="edd-password"><?php _e( 'Password', 'edd' ); ?></label> | |
| <input class="<?php if(edd_no_guest_checkout()) { echo 'required '; } ?>edd-input" type="password" name="edd_user_pass" id="edd_user_pass" placeholder="<?php _e( 'Your password', 'edd' ); ?>"/> | |
| <input type="hidden" name="edd-purchase-var" value="needs-to-login"/> | |
| </p> | |
| <p id="edd-user-login-submit"> | |
| <input type="submit" class="edd-submit button <?php echo $color; ?>" name="edd_login_submit" value="<?php _e( 'Login', 'edd' ); ?>"/> | |
| </p> | |
| <?php do_action('edd_checkout_login_fields_after'); ?> | |
| </fieldset><!--end #edd_login_fields--> | |
| <?php | |
| echo ob_get_clean(); | |
| } | |
| remove_action( 'edd_purchase_form_login_fields', 'edd_get_login_fields' ); | |
| add_action( 'edd_purchase_form_login_fields', 'custom_edd_get_login_fields' ); | |
| /** | |
| * Checkout Login Form | |
| */ | |
| function custom_edd_get_register_fields() { | |
| global $edd_options; | |
| global $user_ID; | |
| if ( is_user_logged_in() ) | |
| $user_data = get_userdata( $user_ID ); | |
| $show_register_form = edd_get_option( 'show_register_form', 'none' ); | |
| ob_start(); ?> | |
| <fieldset id="edd_register_fields"> | |
| <?php if( $show_register_form == 'both' ) { ?> | |
| <p id="edd-login-account-wrap"><?php _e( 'Already have an account?', 'edd' ); ?> <a href="<?php echo add_query_arg('login', 1); ?>" class="edd_checkout_register_login" data-action="checkout_login"><?php _e( 'Login', 'edd' ); ?></a></p> | |
| <?php } ?> | |
| <?php do_action('edd_register_fields_before'); ?> | |
| <fieldset id="edd_register_account_fields"> | |
| <span><legend><?php _e( 'Create an account', 'edd' ); if( !edd_no_guest_checkout() ) { echo ' ' . __( '(optional)', 'edd' ); } ?></legend></span> | |
| <?php do_action('edd_register_account_fields_before'); ?> | |
| <p id="edd-user-login-wrap"> | |
| <label for="edd_user_login"> | |
| <?php _e( 'Username', 'edd' ); ?> | |
| <?php if( edd_no_guest_checkout() ) { ?> | |
| <span class="edd-required-indicator">*</span> | |
| <?php } ?> | |
| </label> | |
| <span class="edd-description"><?php _e( 'The username you will use to log into your account.', 'edd' ); ?></span> | |
| <input name="edd_user_login" id="edd_user_login" class="<?php if(edd_no_guest_checkout()) { echo 'required '; } ?>edd-input" type="text" placeholder="<?php _e( 'Username', 'edd' ); ?>" title="<?php _e( 'Username', 'edd' ); ?>"/> | |
| </p> | |
| <p id="edd-user-pass-wrap"> | |
| <label for="password"> | |
| <?php _e( 'Password', 'edd' ); ?> | |
| <?php if( edd_no_guest_checkout() ) { ?> | |
| <span class="edd-required-indicator">*</span> | |
| <?php } ?> | |
| </label> | |
| <span class="edd-description"><?php _e( 'The password used to access your account.', 'edd' ); ?></span> | |
| <input name="edd_user_pass" id="edd_user_pass" class="<?php if(edd_no_guest_checkout()) { echo 'required '; } ?>edd-input" placeholder="<?php _e( 'Password', 'edd' ); ?>" type="password"/> | |
| </p> | |
| <p id="edd-user-pass-confirm-wrap" class="edd_register_password"> | |
| <label for="password_again"> | |
| <?php _e( 'Password Again', 'edd' ); ?> | |
| <?php if( edd_no_guest_checkout() ) { ?> | |
| <span class="edd-required-indicator">*</span> | |
| <?php } ?> | |
| </label> | |
| <span class="edd-description"><?php _e( 'Confirm your password.', 'edd' ); ?></span> | |
| <input name="edd_user_pass_confirm" id="edd_user_pass_confirm" class="<?php if(edd_no_guest_checkout()) { echo 'required '; } ?>edd-input" placeholder="<?php _e( 'Confirm password', 'edd' ); ?>" type="password"/> | |
| </p> | |
| <?php do_action( 'edd_register_account_fields_after' ); ?> | |
| </fieldset> | |
| <?php do_action('edd_register_fields_after'); ?> | |
| <input type="hidden" name="edd-purchase-var" value="needs-to-register"/> | |
| <?php do_action( 'edd_purchase_form_user_info' ); ?> | |
| </fieldset> | |
| <?php | |
| echo ob_get_clean(); | |
| } | |
| remove_action( 'edd_purchase_form_register_fields', 'edd_get_register_fields' ); | |
| add_action( 'edd_purchase_form_register_fields', 'custom_edd_get_register_fields' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment