Created
February 14, 2019 02:23
-
-
Save greathmaster/9aa6d3a997fd4a82d3eaec98c7d146e0 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
/* | |
Add a "How did you hear about us?" field Membership Checkout for new members only. | |
Display the field for admins-only in the profile and in the Members List CSV export. | |
*/ | |
function my_pmpro_how_hear_fields() { | |
global $current_user; | |
if(class_exists( 'PMProRH_Field' ) && (!pmpro_hasMembershipLevel() || current_user_can( 'edit_users' ) ) ) { | |
pmprorh_add_checkout_box( 'additional', 'Additional Information' ); | |
$fields = array(); | |
//how_hear field | |
$fields[] = new PMProRH_Field( | |
'how_hear', | |
'select', | |
array( | |
'label' => 'How did you hear about us?', | |
'options' => array( | |
'facebook' => 'Facebook', | |
'twitter' => 'Twitter', | |
'friend' => 'Friend', | |
'other' => 'Other' | |
), | |
'profile' => true, | |
'memberslistcsv' => true, | |
'required' => true, | |
) | |
); | |
$fields[] = new PMProRH_Field( | |
'how_hear_referrer', | |
'text', | |
array( | |
'label' => 'Referred by', | |
'profile' => true, | |
'memberslistcsv' => true, | |
'depends' => array(array('id' => 'how_hear', 'value' => 'other')) | |
) | |
); | |
foreach($fields as $field) | |
pmprorh_add_registration_field( 'additional', $field ); | |
} | |
} | |
add_action( 'init', 'my_pmpro_how_hear_fields' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment