Created
April 8, 2021 07:02
-
-
Save AchalJ/de1966a99df8b9d46b40483ee8ac589b to your computer and use it in GitHub Desktop.
Add an extra field to PowerPack's Registration Form module
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
add_filter( 'pp_rf_fields', function( $fields, $settings, $id ) { | |
if ( isset( $fields['consent'] ) ) { | |
$consent = $fields['consent']; | |
unset( $fields['consent'] ); | |
} | |
$fields[] = array( | |
'type' => 'text', | |
'name' => 'company_name', | |
'label' => 'Company Name', | |
'placeholder' => 'Company Name', | |
); | |
if ( isset( $consent ) ) { | |
$fields['consent'] = $consent; | |
} | |
return $fields; | |
}, 10, 3 ); | |
add_action( 'pp_rf_user_register', function( $user_id, $data, $settings ) { | |
if ( isset( $data['company_name'] ) ) { | |
$company_name = sanitize_text_field( $data['company_name'] ); | |
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