Guest User

Untitled

a guest
Feb 18th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.05 KB | None | 0 0
  1. /*
  2. Code demo on using pmprosm_children_fields() and pmprosm_after_child_created() hooks to add additional fields to checkout child account creation.
  3. Adds shipping fields to child accounts at checkout. Use PMPro Shipping Address on Membership Checkout to view
  4. */
  5.  
  6. function pmprosm_additional_child_fields($i, $seats)
  7. {?><label>Shipping Address 1</label><input type="text" name="add_child_saddress1[]" value="" size="20" /><label>Shipping Address 2</label><input type="text" name="add_child_saddress2[]" value="" size="20" /><label>City</label><input type="text" name="add_child_scity[]" value="" size="20" /><label>State</label><input type="text" name="add_child_sstate[]" value="" size="20" /><label>Postal Code</label><input type="text" name="add_child_szipcode[]" value="" size="20" /><?php
  8. }
  9.  
  10. add_action('pmprosm_children_fields', 'pmprosm_additional_child_fields', 10, 2);
  11.  
  12. function pmprosm_save_additional_child_fields($child_user_id, $user_id, $i)
  13. {
  14.  
  15. if(!empty($_REQUEST['add_sub_accounts_first_name']))
  16. $child_first_name = $_REQUEST['add_sub_accounts_first_name'];
  17. else
  18. $child_first_name = '';
  19.  
  20. if(!empty($_REQUEST['add_sub_accounts_last_name']))
  21. $child_last_name = $_REQUEST['add_sub_accounts_last_name'];
  22. else
  23. $child_last_name = '';
  24.  
  25. if(!empty($_REQUEST['add_child_saddress1']))
  26. $child_saddress1 = $_REQUEST['add_child_saddress1'];
  27. else
  28. $child_saddress1 = '';
  29.  
  30. if(!empty($_REQUEST['add_child_saddress2']))
  31. $child_saddress2 = $_REQUEST['add_child_saddress2'];
  32. else
  33. $child_saddress2 = '';
  34.  
  35. if(!empty($_REQUEST['add_child_scity']))
  36. $child_scity = $_REQUEST['add_child_scity'];
  37. else
  38. $child_scity = '';
  39.  
  40. if(!empty($_REQUEST['add_child_sstate']))
  41. $child_sstate = $_REQUEST['add_child_sstate'];
  42. else
  43. $child_sstate = '';
  44.  
  45. if(!empty($_REQUEST['add_child_szipcode']))
  46. $child_szipcode = $_REQUEST['add_child_szipcode'];
  47. else
  48. $child_szipcode = '';
  49.  
  50. if(!empty($child_saddress1))
  51. {
  52. update_user_meta($child_user_id, "pmpro_sfirstname", $child_first_name[$i]);
  53. update_user_meta($child_user_id, "pmpro_slastname", $child_last_name[$i]);
  54. update_user_meta($child_user_id, "pmpro_saddress1", $child_saddress1[$i]);
  55. update_user_meta($child_user_id, "pmpro_saddress2", $child_saddress2[$i]);
  56. update_user_meta($child_user_id, "pmpro_scity", $child_scity[$i]);
  57. update_user_meta($child_user_id, "pmpro_sstate", $child_sstate[$i]);
  58. update_user_meta($child_user_id, "pmpro_szipcode", $child_szipcode[$i]);
  59. }
  60. }
  61.  
  62. add_action('pmprosm_after_child_created', 'pmprosm_save_additional_child_fields', 10, 3);
  63.  
  64. function pmpro_sponsored_member_settings()
  65. {
  66. global $pmprosm_sponsored_account_levels;
  67.  
  68. $pmprosm_sponsored_account_levels = array(
  69. 7 => array(
  70. 'main_level_id' => 7,
  71. 'sponsored_level_id' => array(8),
  72. // 'seats' => 20,
  73. 'seat_cost' => 10,
  74. 'max_seats' => 5,
  75. 'min_seats' => 2,
  76. 'sponsored_accounts_at_checkout' => true,
  77. 'children_get_name' => true,
  78. 'children_hide_username' => false,
  79. 'children_hide_email' => false,
  80. 'children_hide_password' => false,
  81. ),
  82. );
  83.  
  84. }
  85.  
  86. add_action('init', 'pmpro_sponsored_member_settings');
Add Comment
Please, Sign In to add comment