Forked from strangerstudios/my_pmpro_how_hear_field.php
Created
August 26, 2018 08:34
-
-
Save CrandellWS/773ba1807024c15a701eef061f70728e to your computer and use it in GitHub Desktop.
This file contains 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' => 'admins', | |
'memberslistcsv' => true, | |
'required' => true, | |
) | |
); | |
$fields[] = new PMProRH_Field( | |
'how_hear_referrer', | |
'text', | |
array( | |
'label' => 'Referred by', | |
'profile' => 'admins', | |
'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