Guest User

Untitled

a guest
Jul 19th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. <?php
  2. /**
  3. * Use PMPro Register Helper to add PMPro Billing Address fields to the edit user page for admins.
  4. */
  5. /**
  6. * show_pmpro_address_fields_on_edit_profile Grabs the values from the billing fields which get filled in during checkout and displays on User Profile.
  7. *
  8. * @return array Array of Register Helper field objects
  9. */
  10. function show_pmpro_address_fields_on_edit_profile() {
  11. // Require PMPro and PMPro Register Helper
  12. if ( ! defined( 'PMPRO_VERSION' ) || ! defined( 'PMPRORH_VERSION' ) ) {
  13. return;
  14. }
  15.  
  16. // List the fields you want to include
  17. $address_fields = array(
  18. 'pmpro_bfirstname' => 'First Name',
  19. 'pmpro_blastname' => 'Last Name',
  20. 'pmpro_baddress1' => 'Address 1',
  21. 'pmpro_baddress2' => 'Address 2',
  22. 'pmpro_bcity' => 'City',
  23. 'pmpro_bstate' => 'State',
  24. 'pmpro_bzipcode' => 'Zipcode',
  25. 'pmpro_bphone' => 'Phone',
  26. );
  27.  
  28. // Define the fields
  29. $fields = array();
  30. foreach ( $address_fields as $name => $label ) {
  31. $fields[] = new PMProRH_Field(
  32. $name,
  33. 'text',
  34. array(
  35. 'label' => $label,
  36. 'size' => 40,
  37. 'profile' => 'only_admin',
  38. 'addmember' => true,
  39. )
  40. );
  41. }
  42.  
  43. // Add new checkout box with label
  44. pmprorh_add_checkout_box( 'billing_mailing_address', 'Billing/Mailing Address' );
  45.  
  46. // Add fields into a new checkout_boxes area of checkout page
  47. foreach ( $fields as $field ) {
  48. pmprorh_add_registration_field(
  49. 'billing_mailing_address', // location on checkout page
  50. $field // PMProRH_Field object
  51. );
  52. }
  53. }
  54. add_action( 'init', 'show_pmpro_address_fields_on_edit_profile' );
Add Comment
Please, Sign In to add comment