Skip to content

Commit

Permalink
FEATURE: Now showing the User Information section with name fields if…
Browse files Browse the repository at this point in the history
… a user is already logged in at checkout.
  • Loading branch information
ideadude committed Apr 19, 2019
1 parent c477592 commit 5ff8976
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
25 changes: 25 additions & 0 deletions pmpro-add-name-to-checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* Add the fields to the form.
*/
function pmproan2c_pmpro_checkout_after_password() {
global $current_user;

if ( ! empty( $_REQUEST['first_name'] ) ) {
$first_name = sanitize_text_field( $_REQUEST['first_name'] );
} elseif ( ! empty( $_SESSION['first_name'] ) ) {
Expand Down Expand Up @@ -46,6 +48,29 @@ function pmproan2c_pmpro_checkout_after_password() {
}
add_action( 'pmpro_checkout_after_password', 'pmproan2c_pmpro_checkout_after_password' );

/**
* If the user is logged in, we still want to show our version of the account info section.
*/
function pmproan2c_account_info_when_logged_in() {
global $current_user;

if ( ! is_user_logged_in() ) {
return;
}
?>
<hr />
<div id="pmpro_user_fields" class="pmpro_checkout">
<h3>
<span class="pmpro_checkout-h3-name"><?php _e('Account Information', 'pmpro-add-name-to-checkout' );?></span>
</h3>
<div class="pmpro_checkout-fields">
<?php pmproan2c_pmpro_checkout_after_password(); ?>
</div>
</div>
<?php
}
add_action( 'pmpro_checkout_after_pricing_fields', 'pmproan2c_account_info_when_logged_in' );

/**
* Require the fields.
*/
Expand Down
1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Please visit our premium support site at http://www.paidmembershipspro.com for m
* BUG FIX/ENHANCEMENT: Using trim() when checking name fields to disallow blank names.
* ENHANCEMENT: Make add-on translation ready. (Thanks, Thomas Sjolshagen)
* ENHANCEMENT: WordPress coding standards.
* FEATURE: Now showing the User Information section with name fields if a user is already logged in at checkout.

= .3.1 =
* BUG: Fixed error when PHP short tags is disabled.
Expand Down

0 comments on commit 5ff8976

Please sign in to comment.