Created
September 24, 2020 13:56
-
-
Save ipokkel/25acfcb1f1eb9d2f0457edce8e4d4bc8 to your computer and use it in GitHub Desktop.
This recipe creates an additional Terms and Conditions checkbox field.
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 | |
/** | |
* This recipe creates an additional Terms and Conditions check field. | |
* | |
* @requires Register Helper Add On | |
* @link https://www.paidmembershipspro.com/add-ons/pmpro-register-helper-add-checkout-and-profile-fields/ | |
* | |
* 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 my_pmprorh_init_example_fields() { | |
// 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( | |
'por_favor_confirme', // input name, will also be used as meta key | |
'checkbox', // type of field | |
array( | |
'label' => 'Por favor, confirme', | |
'text' => 'Acepto las siguientes condiciones: Libero a la Asociación Centro de Yoga Sivananda Vedanta y a sus profesores de toda responsabilidad en caso de sufrir cualquier daño . Afirmo estar en buena salud y no padecer ninguna enfermedad grave . Asimismo, estoy informado / a de que practico todos los ejercicios bajo mi propio riesgo y propia responsabilidad, y que puedo abstenerme de realizar uno o varios ejercicios en cualquier momento . ', // custom field label | |
'required' => true, // make this field required | |
'profile' => 'admin', // show only to admins on the profile page | |
) | |
); | |
foreach ( $fields as $field ) { | |
pmprorh_add_registration_field( | |
'before_submit_button', // location on checkout page //before_submit_button checkout_boxes | |
$field // PMProRH_Field object | |
); | |
} | |
// that's it. see the PMPro Register Helper readme for more information and examples. | |
} | |
add_action( 'init', 'my_pmprorh_init_example_fields' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment