I’m using WPForms and ACF to get users registered and also get custom info from each user that registers.
I’m finding it problematic to populate the ACF custom fields.
This is what I’ve tried so far:
add_action('wpforms_process_complete', 'map_wpforms_to_acf', 10, 4);
function map_wpforms_to_acf($fields, $entry, $form_data, $entry_id) {
// Replace with your form ID
if ($form_data['id'] != 2623) {
return;
}
// Get the current user ID
$user_id = get_current_user_id();
if (!$user_id) {
return; // Exit if no logged-in user
}
// Retrieve the Physical Address field value
$physical_address = '';
foreach ($fields as $field) {
if (isset($field['name']) && $field['name'] === 'Physical Address') {
$physical_address = sanitize_text_field($field['value']);
break;
}
}
// Check if the Physical Address was provided
if (empty($physical_address)) {
return;
}
// Update the ACF field
update_field('physical_address', $physical_address, 'user_' . $user_id);
}
I have multiple fields that needs to be entered but I’m only trying this test with the Physical Address field so far.
Any assistance would be greatly appreciated.
1
I’ve found the answer myself, in the following video below:
Around minute 28 is where he shows the registration with WPForms and ACF.