Skip to content

Instantly share code, notes, and snippets.

@AchalJ
Last active July 28, 2025 07:28
Show Gist options
  • Select an option

  • Save AchalJ/de1966a99df8b9d46b40483ee8ac589b to your computer and use it in GitHub Desktop.

Select an option

Save AchalJ/de1966a99df8b9d46b40483ee8ac589b to your computer and use it in GitHub Desktop.
Add an extra field to PowerPack's Registration Form module
<?php // <-- ignore this line.
// Add new fields.
add_filter( 'pp_rf_fields', function( $fields, $settings, $id ) {
if ( isset( $fields['consent'] ) ) {
$consent = $fields['consent'];
unset( $fields['consent'] );
}
// Register your fields here.
$fields[] = array(
'type' => 'text', // field type.
'name' => 'company_name', // field name/slug.
'label' => 'Company Name', // field label.
'placeholder' => 'Company Name', // field placeholder.
);
if ( isset( $consent ) ) {
$fields['consent'] = $consent;
}
return $fields;
}, 10, 3 );
// Logic to store the custom field value to the user meta.
add_action( 'pp_rf_user_register', function( $user_id, $data, $settings ) {
if ( isset( $data['company_name'] ) ) {
// Validate the field. You can add any additional validation here.
$company_name = sanitize_text_field( $data['company_name'] );
// Store the value.
update_user_meta( $user_id, 'company_name', $company_name );
}
}, 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment