ISSUE: We are not collecting phone numbers during registration.
Fix: According to the Knowledgebase, this should be possible by updating the functions.php file. The updated code will do the following:
- Add the phone number field to the registration form.
- Validate the phone number field during registration.
- Save the phone number when registration is processed.
- Add the phone number field to the “Contact Info” section of the WordPress user profile.
@HipGnosis, I’m still working on setting up the webhook to send this information to n8n, but the phone numbers will be stored in user settings.
Current functions.php (backup in case new edits break everything)
<?php
/**
* Register/enqueue custom scripts and styles
*/
add_action( 'wp_enqueue_scripts', function() {
// Enqueue your files on the canvas & frontend, not the builder panel. Otherwise custom CSS might affect builder)
if ( ! bricks_is_builder_main() ) {
wp_enqueue_style( 'bricks-child', get_stylesheet_uri(), ['bricks-frontend'], filemtime( get_stylesheet_directory() . '/style.css' ) );
}
} );
/**
* Register custom elements
*/
add_action( 'init', function() {
$element_files = [
__DIR__ . '/elements/title.php',
];
foreach ( $element_files as $file ) {
\Bricks\Elements::register_element( $file );
}
}, 11 );
/**
* Add text strings to builder
*/
add_filter( 'bricks/builder/i18n', function( $i18n ) {
// For element category 'custom'
$i18n['custom'] = esc_html__( 'Custom', 'bricks' );
return $i18n;
} );
/**
* Display the full access Zoom Join URL with embedded password with everyone, including anonymous site visitors.
*/
add_filter( 'tribe_events_virtual_meetings_zoom_meeting_include_password', '__return_true' );
Updated functions.php
<?php
/***
* Register/enqueue custom scripts and styles
*/
add_action( 'wp_enqueue_scripts', function() {
// Enqueue your files on the canvas & frontend, not the builder panel. Otherwise custom CSS might affect builder)
if ( ! bricks_is_builder_main() ) {
wp_enqueue_style( 'bricks-child', get_stylesheet_uri(), ['bricks-frontend'], filemtime( get_stylesheet_directory() . '/style.css' ) );
}
} );
/***
* Register custom elements
*/
add_action( 'init', function() {
$element_files = [
__DIR__ . '/elements/title.php',
];
foreach ( $element_files as $file ) {
\Bricks\Elements::register_element( $file );
}
}, 11 );
/***
* Add text strings to builder
*/
add_filter( 'bricks/builder/i18n', function( $i18n ) {
// For element category 'custom'
$i18n['custom'] = esc_html__( 'Custom', 'bricks' );
return $i18n;
} );
/***
* Display the full access Zoom Join URL with embedded password with everyone, including anonymous site visitors.
*/
add_filter( 'tribe_events_virtual_meetings_zoom_meeting_include_password', '__return_true' );
/***
* Restrict Content Pro - Add Phone Number Field
* The following functions add a phone number field to the RCP registration form and WordPress user profiles
*/
// Add phone number field to RCP registration form
function add_phone_number_field() {
?>
<p>
<label for="rcp_phone"><?php _e( 'Phone Number', 'rcp' ); ?></label>
<input name="rcp_phone" id="rcp_phone" type="tel" />
</p>
<?php
}
add_action( 'rcp_after_password_registration_field', 'add_phone_number_field' );
// Validate phone number field during registration
function validate_phone_number_field( $posted ) {
if ( empty( $posted['rcp_phone'] ) ) {
rcp_errors()->add( 'empty_phone', __( 'Please enter your phone number', 'rcp' ), 'register' );
}
}
add_action( 'rcp_form_errors', 'validate_phone_number_field' );
// Save phone number to user meta when registration is processed
function save_phone_number( $posted ) {
if ( ! empty( $posted['rcp_phone'] ) ) {
$user_id = get_current_user_id();
update_user_meta( $user_id, 'rcp_phone', sanitize_text_field( $posted['rcp_phone'] ) );
}
}
add_action( 'rcp_form_processing', 'save_phone_number', 10, 1 );
// Add phone number field to WordPress user profile in Contact Info section
function add_phone_number_to_user_profile( $user_contact_methods ) {
$user_contact_methods['rcp_phone'] = __( 'Phone Number', 'rcp' );
return $user_contact_methods;
}
add_filter( 'user_contactmethods', 'add_phone_number_to_user_profile' );
// Save phone number when user profile is updated
function save_phone_number_user_profile( $user_id ) {
if ( ! current_user_can( 'edit_user', $user_id ) ) {
return false;
}
if ( isset( $_POST['rcp_phone'] ) ) {
update_user_meta( $user_id, 'rcp_phone', sanitize_text_field( $_POST['rcp_phone'] ) );
}
}
add_action( 'personal_options_update', 'save_phone_number_user_profile' );
add_action( 'edit_user_profile_update', 'save_phone_number_user_profile' );