Created
July 1, 2016 13:35
-
-
Save andrewteg/fe92720f506e3047de0528b54331bece to your computer and use it in GitHub Desktop.
A Paid Memberships Pro Register Helper Extension Example (pmpro-register-helper-fields)
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
<?php | |
/* | |
Plugin Name: Register Helper Example | |
Plugin URI: http://www.paidmembershipspro.com/wp/pmpro-customizations/ | |
Description: Register Helper Initialization Example | |
Version: .1 | |
Author: Stranger Studios | |
Author URI: http://www.strangerstudios.com | |
*/ | |
//we have to put everything in a function called on init, so we are sure Register Helper is loaded | |
function my_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( | |
"Auditions", // input name, will also be used as meta key | |
"checkbox", // type of field | |
array( | |
//"text"=>"Checkbox Text", //not usually needed but if used, this will change the text next to the checkbox and the name will be put on the left using an HTML label tag instead | |
"class"=>"myclass", // custom class for custom CSS if needed | |
"profile"=>true, // Should this field also be shown in the profile? Valid values are true, false, “only”, or “only_admin” | |
)); | |
$fields[] = new PMProRH_Field( | |
"Stage Management", // input name, will also be used as meta key | |
"checkbox", // type of field | |
array( | |
"profile"=>true, | |
)); | |
$fields[] = new PMProRH_Field( | |
"Backstage Crew", | |
"checkbox", | |
array( | |
"profile"=>true, | |
)); | |
$fields[] = new PMProRH_Field( | |
"Publicity", | |
"checkbox", | |
array( | |
"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", "my_pmprorh_init"); |
Sorry @kingvish, just now saw this and not sure why. Best I can see is https://gist.github.com/andrewlimaza/82417f361ff99d800346f55dfe93e33b who is creating a checkbox as HTML. I'm not sure if there's a better way yet or not!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How to make those checkbox checked by default?