Last active
August 16, 2021 16:11
-
-
Save femiyb/de2a77f5aae4760e576b983d580290ca to your computer and use it in GitHub Desktop.
Upload file with delete option and allow extension option
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 | |
/** | |
* This example is to show you the 'niche' options each Paid Memberships Pro - Register Helper Add-on field can take and how to use it. | |
* For more information on the Register Helper Add-on please visit https://www.paidmembershipspro.com/add-ons/free-add-ons/pmpro-register-helper-add-checkout-and-profile-fields/ | |
**/ | |
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( | |
"photo", // input name, will also be used as meta key | |
"file", // type of field | |
array( | |
'accept' => ".jpg", // accept .jpg file extension (http://www.w3schools.com/TAGs/att_input_accept.asp) | |
'memberslistcsv' => true, | |
'required' => true, // make field required, set value to false to make it optional | |
'profile' => true, | |
'allow_delete' => true | |
) | |
); | |
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"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment