Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow rendering current field values on checkout if user is logged in #17

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 47 additions & 45 deletions src/PMPro/Objects/Member_Checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,15 @@ public function unhook() {
* Render the fields for the checkout page in the after level cost section.
*
* @since 1.0.0
*
* @param WP_User|null $user The user object or null if not provided.
*/
public function pmpro_checkout_after_level_cost( $user = null ) {
public function pmpro_checkout_after_level_cost() {
if ( ! empty( $GLOBALS['pmpro_review'] ) ) {
return;
}

pods_form_render_fields( 'pmpro_membership_user', $user ? $user->ID : null, [
$user_id = is_user_logged_in() ? get_current_user_id() : null;

pods_form_render_fields( 'pmpro_membership_user', $user_id, [
'section_field' => 'pmpro_section_checkout',
'section' => 'after_level_cost',
'render' => 'div-rows',
Expand All @@ -143,15 +143,15 @@ public function pmpro_checkout_after_level_cost( $user = null ) {
* Render the fields for the checkout page in the after pricing fields section.
*
* @since 1.0.0
*
* @param WP_User|null $user The user object or null if not provided.
*/
public function pmpro_checkout_after_pricing_fields( $user = null ) {
public function pmpro_checkout_after_pricing_fields() {
if ( ! empty( $GLOBALS['pmpro_review'] ) ) {
return;
}

pods_form_render_fields( 'pmpro_membership_user', $user ? $user->ID : null, [
$user_id = is_user_logged_in() ? get_current_user_id() : null;

pods_form_render_fields( 'pmpro_membership_user', $user_id, [
'section_field' => 'pmpro_section_checkout',
'section' => 'after_pricing_fields',
'render' => 'div-rows',
Expand All @@ -171,15 +171,15 @@ public function pmpro_checkout_after_pricing_fields( $user = null ) {
* Render the fields for the checkout page in the after username section.
*
* @since 1.0.0
*
* @param WP_User|null $user The user object or null if not provided.
*/
public function pmpro_checkout_after_username( $user = null ) {
public function pmpro_checkout_after_username() {
if ( ! empty( $GLOBALS['pmpro_review'] ) ) {
return;
}

pods_form_render_fields( 'pmpro_membership_user', $user ? $user->ID : null, [
$user_id = is_user_logged_in() ? get_current_user_id() : null;

pods_form_render_fields( 'pmpro_membership_user', $user_id, [
'section_field' => 'pmpro_section_checkout',
'section' => 'after_username',
'render' => 'div-rows',
Expand All @@ -192,15 +192,15 @@ public function pmpro_checkout_after_username( $user = null ) {
* Render the fields for the checkout page in the after password section.
*
* @since 1.0.0
*
* @param WP_User|null $user The user object or null if not provided.
*/
public function pmpro_checkout_after_password( $user = null ) {
public function pmpro_checkout_after_password() {
if ( ! empty( $GLOBALS['pmpro_review'] ) ) {
return;
}

pods_form_render_fields( 'pmpro_membership_user', $user ? $user->ID : null, [
$user_id = is_user_logged_in() ? get_current_user_id() : null;

pods_form_render_fields( 'pmpro_membership_user', $user_id, [
'section_field' => 'pmpro_section_checkout',
'section' => 'after_password',
'render' => 'div-rows',
Expand All @@ -213,15 +213,15 @@ public function pmpro_checkout_after_password( $user = null ) {
* Render the fields for the checkout page in the after email section.
*
* @since 1.0.0
*
* @param WP_User|null $user The user object or null if not provided.
*/
public function pmpro_checkout_after_email( $user = null ) {
public function pmpro_checkout_after_email() {
if ( ! empty( $GLOBALS['pmpro_review'] ) ) {
return;
}

pods_form_render_fields( 'pmpro_membership_user', $user ? $user->ID : null, [
$user_id = is_user_logged_in() ? get_current_user_id() : null;

pods_form_render_fields( 'pmpro_membership_user', $user_id, [
'section_field' => 'pmpro_section_checkout',
'section' => 'after_email',
'render' => 'div-rows',
Expand All @@ -242,7 +242,9 @@ public function pmpro_checkout_after_user_fields( $user = null ) {
return;
}

pods_form_render_fields( 'pmpro_membership_user', $user ? $user->ID : null, [
$user_id = is_user_logged_in() ? get_current_user_id() : null;

pods_form_render_fields( 'pmpro_membership_user', $user_id, [
'section_field' => 'pmpro_section_checkout',
'section' => 'after_user_fields',
'render' => 'div-rows',
Expand All @@ -262,15 +264,15 @@ public function pmpro_checkout_after_user_fields( $user = null ) {
* Render the fields for the checkout page in the checkout boxes section.
*
* @since 1.0.2
*
* @param WP_User|null $user The user object or null if not provided.
*/
public function pmpro_checkout_boxes( $user = null ) {
public function pmpro_checkout_boxes() {
if ( ! empty( $GLOBALS['pmpro_review'] ) ) {
return;
}

pods_form_render_fields( 'pmpro_membership_user', $user ? $user->ID : null, [
$user_id = is_user_logged_in() ? get_current_user_id() : null;

pods_form_render_fields( 'pmpro_membership_user', $user_id, [
'section_field' => 'pmpro_section_checkout',
'section' => 'boxes',
'render' => 'div-rows',
Expand All @@ -290,15 +292,15 @@ public function pmpro_checkout_boxes( $user = null ) {
* Render the fields for the checkout page in the after billing fields section.
*
* @since 1.0.0
*
* @param WP_User|null $user The user object or null if not provided.
*/
public function pmpro_checkout_after_billing_fields( $user = null ) {
public function pmpro_checkout_after_billing_fields() {
if ( ! empty( $GLOBALS['pmpro_review'] ) ) {
return;
}

pods_form_render_fields( 'pmpro_membership_user', $user ? $user->ID : null, [
$user_id = is_user_logged_in() ? get_current_user_id() : null;

pods_form_render_fields( 'pmpro_membership_user', $user_id, [
'section_field' => 'pmpro_section_checkout',
'section' => 'after_billing_fields',
'render' => 'div-rows',
Expand All @@ -318,15 +320,15 @@ public function pmpro_checkout_after_billing_fields( $user = null ) {
* Render the fields for the checkout page in the after payment information fields section.
*
* @since 1.0.0
*
* @param WP_User|null $user The user object or null if not provided.
*/
public function pmpro_checkout_after_payment_information_fields( $user = null ) {
public function pmpro_checkout_after_payment_information_fields() {
if ( ! empty( $GLOBALS['pmpro_review'] ) ) {
return;
}

pods_form_render_fields( 'pmpro_membership_user', $user ? $user->ID : null, [
$user_id = is_user_logged_in() ? get_current_user_id() : null;

pods_form_render_fields( 'pmpro_membership_user', $user_id, [
'section_field' => 'pmpro_section_checkout',
'section' => 'after_payment_information_fields',
'render' => 'div-rows',
Expand All @@ -346,15 +348,15 @@ public function pmpro_checkout_after_payment_information_fields( $user = null )
* Render the fields for the checkout page in the after TOS fields section.
*
* @since 1.0.0
*
* @param WP_User|null $user The user object or null if not provided.
*/
public function pmpro_checkout_after_tos_fields( $user = null ) {
public function pmpro_checkout_after_tos_fields() {
if ( ! empty( $GLOBALS['pmpro_review'] ) ) {
return;
}

pods_form_render_fields( 'pmpro_membership_user', $user ? $user->ID : null, [
$user_id = is_user_logged_in() ? get_current_user_id() : null;

pods_form_render_fields( 'pmpro_membership_user', $user_id, [
'section_field' => 'pmpro_section_checkout',
'section' => 'after_tos_fields',
'render' => 'div-rows',
Expand All @@ -374,15 +376,15 @@ public function pmpro_checkout_after_tos_fields( $user = null ) {
* Render the fields for the checkout page in the after captcha section.
*
* @since 1.0.0
*
* @param WP_User|null $user The user object or null if not provided.
*/
public function pmpro_checkout_after_captcha( $user = null ) {
public function pmpro_checkout_after_captcha() {
if ( ! empty( $GLOBALS['pmpro_review'] ) ) {
return;
}

pods_form_render_fields( 'pmpro_membership_user', $user ? $user->ID : null, [
$user_id = is_user_logged_in() ? get_current_user_id() : null;

pods_form_render_fields( 'pmpro_membership_user', $user_id, [
'section_field' => 'pmpro_section_checkout',
'section' => 'after_captcha',
'render' => 'div-rows',
Expand All @@ -402,15 +404,15 @@ public function pmpro_checkout_after_captcha( $user = null ) {
* Render the fields for the checkout page in the before submit button section.
*
* @since 1.0.0
*
* @param WP_User|null $user The user object or null if not provided.
*/
public function pmpro_checkout_before_submit_button( $user = null ) {
public function pmpro_checkout_before_submit_button() {
if ( ! empty( $GLOBALS['pmpro_review'] ) ) {
return;
}

pods_form_render_fields( 'pmpro_membership_user', $user ? $user->ID : null, [
$user_id = is_user_logged_in() ? get_current_user_id() : null;

pods_form_render_fields( 'pmpro_membership_user', $user_id, [
'section_field' => 'pmpro_section_checkout',
'section' => 'before_submit_button',
'render' => 'div-rows',
Expand Down