Registration Form custom ACF User meta

Sup Bricks Fam,
I have been trying to hook a registration form to custom user meta (Age, Origin…), that I have set up in ACF.

The Forms Task: Register User with data that will be partially filled into custom user meta fields created with ACF

I know that this can be achieved by using third party plugins, but I specifically want to use bricks builder as I want to have full customizability when it comes to design and also because I do not want to pay a monthly fee for a single feature.

I am not that big in PHP, but I know that there is a documentation on CUSTOM FORMS inside of bricks academy, which I partly understand.

My hope is that someone has already resolved this for him/herself and is willing to share their blueprint for me to understand.

Thank you in advance!
Tobi

No sure if you figured this out yet or not, what I did though, was used the custom action and added this code for my custom fields to update it.

function my_form_custom_action( $form) {  
	
	// $formId = $fields['formId'];
	// $postId = $fields['postId'];
	$settings = $form->get_settings();
	// $files = $form->get_uploaded_files();
	$fields = $form->get_fields();
	$user_id =  get_current_user_id();
  	foreach ($settings['fields'] as $field) {
    if (isset($field['label']) && $field['label'] == 'form-id') {
      if ( $field['value'] == 'update_user') {
  		if ($fields['form-field-99c370'] != null) {
			update_user_meta( $user_id, 'first_name', $fields['form-field-99c370']);
		}
  		if ($fields['form-field-yuetdu'] != null) {
			update_user_meta( $user_id, 'last_name', $fields['form-field-yuetdu']);
		}
  		if ($fields['form-field-srcbkn'] != null) {
  			update_user_meta( $user_id, 'company', $fields['form-field-srcbkn']);
		}
  		if ($fields['form-field-mfobhg'] != null) {
  			update_user_meta( $user_id, 'phone_number', $fields['form-field-mfobhg']);  		
		}
		if ($fields['form-field-clfpcb'] != null) {
			update_user_meta( $user_id, 'postal_code', $fields['form-field-clfpcb']);
		}
	  }
      if ( $field['value'] == 'register') {
  		update_user_meta( $user_id, 'company', $fields['form-field-syybci']);
  		update_user_meta( $user_id, 'phone_number', $fields['form-field-wehnqf']);
  		update_user_meta( $user_id, 'postal_code', $fields['form-field-ufzomx']);
	  }
    }
  }
}
add_action( 'bricks/form/custom_action', 'my_form_custom_action', 10, 1 );

Basically, once the person registers, the form does the auto-login, which allows the custom action to retrieve their user-id and make the updates accordingly. i also had a separate form to update the fields later one, so their is a hidden field on both forms for form-id, that way the code could be made to handle differently for a registration vs an update.

I had looked into maybe creating an extension to the form element, or the registration action somehow to include the extra custom fields a different way, but I don’t know that much so couldn’t really figure it out without creating a bunch of other issues.

Hopefully this helps, I think I initially figured it out from a different forum post somewhere on here.

I have figured it out, I have done it the same way as you. Thank you for your reply anyway - I am sure someone will be helped with this for sure!

Best,
Tobi

Hello @Mundy,
I am trying to do the same thing - mapping the Bricks forms fields with user custom fields I have created by Metabox. I spend almost an hour, trying to implement your solution in my case, but without success.
So, to be clear - I need to register a user with the Bricks form, but I have additional form fields, which are not default user fields. Such as Company name, Address, etc…

I was thinking - maybe I have to activate “Auto log user” in Bricks form (?).
If this is the reason why the process doesn’t work in my case - I may not activate that unfortunately.
Or maybe the process is a bit different due to Metabox and not ACF (although I won’t bet on that).
Thank you regardless of your answer.

@SinjoriS yeah, you need to auto login the user for this to work. The tool for the custom fields shouldn’t matter as I actually used pods.

You could make sure the default user role has no access so it doesn’t matter if they are logged in.

There also might be a way to add some code to what I did that logs them out after adding the fields.

The other option I considered at the time was just having the custom action do the entire create user process and just custom code the whole thing.