Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ipokkel/6f860b34224518f459c686896b7ac157 to your computer and use it in GitHub Desktop.
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).
<?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