Created
January 13, 2026 22:43
-
-
Save greenhornet79/b3d760c90db08c3dd4031119db18d5db to your computer and use it in GitHub Desktop.
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 | |
| // add fields to the gift form | |
| add_action('lp_gift_sub_after_recipient_fields', 'endo_add_custom_fields_on_gift_form' ); | |
| function endo_add_custom_fields_on_gift_form() { | |
| ?> | |
| <p> | |
| <label>Your coworking space</label> | |
| <input name="coworking_space" value="" placeholder="where do you work?"> | |
| </p> | |
| <?php | |
| } | |
| // add the submitted fields to the gift details array | |
| add_filter('lp_gift_subs_details_checkout_array', 'endo_add_custom_fields_to_gift_details', 20, 2); | |
| function endo_add_custom_fields_to_gift_details($data, $fields) { | |
| if (isset($fields['coworking_space']) && $fields['coworking_space']) { | |
| $data['coworking_space'] = sanitize_text_field($fields['coworking_space']); | |
| } | |
| return $data; | |
| } | |
| // store the data on the user, transaction, etc. | |
| add_action('leaky_paywall_after_process_gift_subscription', 'endo_process_gift_subscription'); | |
| function endo_process_gift_subscription($gift_details) { | |
| $email = $gift_details['rcpt_email']; | |
| $user = get_user_by('email', $email); | |
| $transaction_id = leaky_paywall_get_transaction_id_from_email($user->user_email); | |
| if (isset($gift_details['coworking_space']) && $gift_details['coworking_space']) { | |
| update_post_meta($transaction_id, '_coworking_space', $gift_details['coworking_space']); | |
| update_user_meta($user->ID, '_coworking_space', $gift_details['coworking_space']); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment