Created
November 24, 2021 03:12
-
-
Save ipokkel/6f860b34224518f459c686896b7ac157 to your computer and use it in GitHub Desktop.
Collect the default WordPress user fields for the Bioraphicall info (discription) and Website URL (user_url).
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 | |
/** | |
* Add Website and Biographical Info to Membership Checkout | |
* | |
* 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_default_wp_user_checkout_fields() { | |
if ( class_exists( 'PMProRH_Field' ) ) { | |
// Create custom checkout box area. | |
pmprorh_add_checkout_box( 'additional', 'Additional Information' ); | |
// Start fields | |
$fields = array(); | |
// Conditional to show only on frontend. Useful for WP default fields already on user edit profile page. | |
$your_profile = is_admin() ? false : true; | |
// user_url field | |
$fields[] = new PMProRH_Field( | |
'user_url', | |
'text', | |
array( | |
'label' => 'Website', | |
'size' => 40, | |
'profile' => $your_profile, | |
'required' => false, | |
) | |
); | |
// description field | |
$fields[] = new PMProRH_Field( | |
'description', | |
'textarea', | |
array( | |
'label' => 'Biographical Info', | |
'size' => 40, | |
'profile' => $your_profile, | |
'required' => false, | |
) | |
); | |
foreach ( $fields as $field ) { | |
pmprorh_add_registration_field( 'additional', $field ); | |
} | |
} | |
} | |
add_action( 'init', 'my_pmprorh_default_wp_user_checkout_fields' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment