Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Support Kris – WPMU DEV Support

    (@wpmudevsupport13)

    Hi @geoffreygordon

    I hope you are doing well today.

    Apart from the ACF plugin, could you let us know if is there any other plugin you use to display those data on the front end (aside from the ACF I guess there is some membership or user profile plugin)? We would like to fully replicate this issue.

    With that additional data, it will be good to have your form exported as well. You can upload your form to Google Drive and share a link in your next reply.

    Kind Regards,
    Kris

    Thread Starter geoffreygordon

    (@geoffreygordon)

    Showing in the front end is not the issue it works just fine. its displaying the information on the backend that I need. I just want to see the check boxes on the back end on the users profile that is all.

    Thread Starter geoffreygordon

    (@geoffreygordon)

    Plugin Support Williams – WPMU DEV Support

    (@wpmudev-support8)

    Hi @geoffreygordon

    I’m still not sure if I correctly understand the problem but let’s see about that:

    1. Form in question seems fine; I imported it and I see it has checkbox field added

    2. that checkbox field is mapped to some custom user profile field via the “custom meta” option in the “user registration” settings.

    Now, if I’m getting this right, the problem is that this custom user meta is an ACF field and it’s in ACF set to be of checkbox type. Is that correct?

    If yes, then this outcome is expected. Forminator support custom meta data but in a generic, basic form only. ACF extends standard WordPress custom meta – allowing you use different types of fields but it does so by storing data in specific formats and then handling display of that data on its own. It is not core WordPress functionality.

    And there is no such full compatibility specifically for ACF in Forminator.

    Basically, simple fields with basic “open text” data will work but more complex formats would need custom code to make them compatible. So the chekbox field data, as provided by Forminator, would have to be then converted to the format expected by ACF upon submission and then user meta would have to be additionally updated to override the data with correct format.

    —-

    All in all, it would require additional custom code. If you can confirm that I correctly understood the problem and you are using ACF user fields of type (in ACF) checkbox – we can ask our Second Line Support to see if there’d be some workaround.

    I can’t make promises as it requires custom coding which may go out of the scope of this support. But we’ll ask, just let us know if that’s the case.

    Kind regards,
    Adam

    Thread Starter geoffreygordon

    (@geoffreygordon)

    Hi Adam

    It seems you are reading the situation mostly right. I have created a video just to illustrate the issue and make it super clear. I would be happy to pay for the extra support just to finish this last part off if necessary. I need the solution urgently.

    Here is the link to the video to explain things more clearly.
    https://drive.google.com/file/d/1tlUdaQBfcDJ4Htk5kbFVPEjRWhRcf0Hb/view?usp=sharing

    Plugin Support Williams – WPMU DEV Support

    (@wpmudev-support8)

    Hi @geoffreygordon

    Okay, that’s all clear now (thanks for the video!).

    As I suspected, this is about compatibility. All the “text” type fields will work just fine as Forminator is passing data in a “raw text” format but ACF’s “select” and “checkbox” fields (as well as radio, image, gallery, file and some other, in case you’d be using them) – they all need to have form data converted with an additional custom code.

    This is not and never have been built-in into the plugin so I’m actually quite surprised that it was included in some tutorial video (by the way, was that our tutorial or some 3rd-party video?).

    But anyway, I believe we can help with this.

    ————–

    First, you need to make sure about some basic prerequisites.

    1. in the registration form settings

    a) in “Settings” make sure that “Multiple Option Value” option is set to “Option Values”

    b) then in both your checkbox and your select fields on the form make sure that the VALUES (not labels) of the options are set EXACTLY the same (including lower/upper case characters, spaces etc; be careful about special characters – they may not be supported) as relevant options for select and checkbox field configured in ACF.

    By “the same” I mean that if e.g. in ACF checkbox field you have options

    Option A
    Option B
    something else

    then relevant checkbox on the form MUST have its options’ values set to be exactly that

    Option A
    Option B
    something else

    c) and make sure that form fields are correctly mapped to ACF fields; by “correctly” I mean that in “Custom User Meta” you need the first field (label) of each filed to be set to exact ACF field name; then in second field you choose the form field to map it to.

    I believe you already have it done since text fields are correctly saved.

    2. Add this code to the site as Must Use plugin:

    <?php 
    
    add_action( 'forminator_cform_user_registered', 'forminator_acf_user_compat', 99, 3 );
    function forminator_acf_user_compat( $user_id, $custom_form, $entry ) {
    	
    	$forms = array( 123, 18098 ); // comma separated list of form IDs to apply this to
    	
    	// list of ACF checkbox fields to be made compatible
    	// format
    	// 'acf_field_name' => 'form_field_id' 
    	
    	$checkboxes = array( 
    		'my_checkbox' => 'checkbox-1', 
    	); 
    	
    	# do not edit below
    
    	if ( !in_array( $custom_form->id, $forms ) ) {
    		return;
    	}
    
    	$form_data = $entry->meta_data;
    	
    	$field = '';
    	$acf_format = array();
    	
    	//convert and update checkboxes
    	foreach ($checkboxes as $acf => $formi) { 
    	
    		if ( array_key_exists( $formi, $form_data ) ) {
    			
    			$field = $form_data[$formi]['value'];
    			$acf_format = explode( ',', $field);
    			foreach ( $acf_format as $a=>$b) {
    				$acf_format[$a] = trim($b);
    			}
    			
    			update_user_meta( $user_id, $acf, $acf_format );			
    		
    		}	
    	
    	} 
    	
    	
    }

    To do that:

    – create an empty file with .php extension (e.g. “forminator-user-acf-compatibility.php”) in the “/wp-content/mu-plugins” folder of your site’s WordPress install

    – copy and paste code into it

    – in this line of the code replace numbers with form IDs of the forms that you want that to be applied to

    $forms = array( 123, 18098 );

    – in this part you need to “map” fields again

    $checkboxes = array( 
    		'my_checkbox' => 'checkbox-1', 
    	); 

    Basically, on the left it’s ACF field name, on the right it’s form field ID (but without curly brackets). I hope this is understandable.

    Note that this is only about checkbox type fields, you don’t add select type fields here.

    Save the file and that’s pretty much it.

    If it’s all set and added correctly, checkboxes now should be properly reflected in user profile. I tested it with ACF and it works exactly as it should.

    As for select type fields – in my tests it actually does work out of the box, provided that

    a) select filed on the form is NOT set to be “multiselect” (it’s just a regular single select)

    b) and its options’ values are exactly the same as options in ACF in relevant field (see point 1b earlier).

    Best regards,
    Adam

    Thread Starter geoffreygordon

    (@geoffreygordon)

    Hi Adam

    I tried to do what you suggested above but not seeing any changes, if I gave you logins could you help please ?

    Plugin Support Williams – WPMU DEV Support

    (@wpmudev-support8)

    Hi @geoffreygordon

    Thank you for response!

    Please note that asking or offering (in general – sharing) any access credentials is strictly prohibited here. Neither you are allowed to suggest that, nor we are allowed to ask or accept it.

    As for the issue, I’m marking this ticket as resolved for now since the code solution itself is correct and we are already supporting you elsewhere.

    Kind regards,
    Adam

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Check, multiselct not showing’ is closed to new replies.