Last active
September 24, 2020 06:23
-
-
Save AchalJ/f168e7fab29439cd0addcabcfaa07759 to your computer and use it in GitHub Desktop.
Extend Beaver Builder PowerPack Registration Form
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 fields. | |
add_filter( 'pp_rf_fields', function( $fields, $settings, $id ) { | |
if ( isset( $fields['consent'] ) ) { | |
$consent = $fields['consent']; | |
unset( $fields['consent'] ); | |
} | |
$fields[] = array( | |
'name' => 'meta_address_field', | |
'label' => 'Address', | |
'type' => 'textarea', | |
'placeholder' => 'Address' | |
); | |
$fields[] = array( | |
'name' => 'meta_phone_field', | |
'label' => 'Phone', | |
'type' => 'text', | |
'placeholder' => 'Phone' | |
); | |
if ( isset( $consent ) ) { | |
$fields['consent'] = $consent; | |
} | |
return $fields; | |
}, 10, 3 ); | |
// Save the fields. | |
add_action( 'pp_rf_user_register', function( $user_id, $data, $settings ) { | |
if ( isset( $data['meta_address_field'] ) ) { | |
update_user_meta( $user_id, 'meta_address_field', $data['meta_address_field'] ); | |
} | |
if ( isset( $data['meta_phone_field'] ) ) { | |
update_user_meta( $user_id, 'meta_phone_field', $data['meta_phone_field'] ); | |
} | |
}, 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment