Created
July 25, 2020 13:03
-
-
Save kimcoleman/02e8ec055d49433352c4147db28d8fb4 to your computer and use it in GitHub Desktop.
Custom fields at membership checkout for support ticket.
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 | |
/** | |
* Custom fields at membership checkout for support ticket. | |
* | |
* Requires: Paid Memberships Pro, Register Helper Add On. | |
* | |
* You can add this recipe to your site by creating a custom plugin | |
* or using the Code Snippets plugin available for free in the WordPress repository. | |
* Read this companion article for step-by-step directions on either method. | |
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ | |
function butlercountyogs_pmprorh_init() { | |
//don't break if Register Helper is not loaded | |
if ( ! function_exists( "pmprorh_add_registration_field" ) ) { | |
return false; | |
} | |
//define the fields | |
$fields = array(); | |
$fields[] = new PMProRH_Field( | |
"surnames", | |
"textarea", | |
array( | |
"label"=>"Surnames you are researching", | |
"profile"=>true, | |
)); | |
$fields[] = new PMProRH_Field( | |
"newletter_type", | |
"radio", | |
array( | |
"label"=>"Newsletter Format", | |
"options"=>array( | |
"email"=>"Email", | |
"mail"=>"Physical Mail", | |
), | |
"profile"=>true, | |
)); | |
//add the fields into a new checkout_boxes are of the checkout page | |
foreach($fields as $field) | |
pmprorh_add_registration_field( | |
"checkout_boxes", // location on checkout page | |
$field // PMProRH_Field object | |
); | |
//that's it. see the PMPro Register Helper readme for more information and examples. | |
} | |
add_action("init", "butlercountyogs_pmprorh_init"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment