himitsuu
Forum Replies Created
-
@wpmudev-support7
Thank you very much! This code is now working!But how can I map the selection to an ACF Field of type User?
@wpmudev-support8
Hello,I double-checked and realized that I had hardcoded my two users as options in my {select-1} component. As a result, the functionality is currently not working for me. This issue affects not only the first user but also others.I triple-checked and discovered that the code is hardcoding the user into the backend, which is quite amusing. However, this issue is still limited to only the first selection field.
ACF:
https://drive.google.com/file/d/1QjPINuca3WP4G6lbUl6j1kYtbgH_ihQ5/view?usp=sharing
Forminator:
https://drive.google.com/file/d/15gZ5Sjx-cA4g85yVL3fDbp8EmqnNS21C/view?usp=sharingThank you for your response! I appreciate the progress made so far, although there are a few remaining issues:
- The solution is working only for the first selection field.
(https://i.gyazo.com/88268c06a15157aaff42ec5c596507ee.mp4) - Fortunately, the user data is successfully saved in the post custom data.
(https://i.gyazo.com/59315c350cae15dd37844ba25764e752.png) - Unfortunately, the ACF field “user” is not capturing the value.
(https://i.gyazo.com/5e89d2a8d10b809feed7f0ff0ea2f5dc.png) - Perhaps it would be better to work with text fields instead of trying to map user fields together.”
It seems that mapping user fields together is not possible. In that case, it might be better to work with just text fields instead?
Thank you for your response!
Unfortunately, the solution you provided doesn’t seem to be working at the moment.
Did I make any mistakes in my implementation? Should this new PHP code you provided be placed in the MU-Plugins directory?
PS: my field name is still selected-1.
https://i.gyazo.com/62bad83a19dd19ea32e04720c5f84ae1.png
if it would work, could i just add the other two sections like this?$select_fields_data = array( 'select-1' => 'users', 'select-2' => 'users', 'select-3' => 'users' );
Here is the code I used:
<?php add_filter( 'forminator_cform_render_fields', function( $wrappers, $model_id ) { if ( $model_id != 2101 ) { return $wrappers; } $select_fields_data = array( 'select-1' => 'users', ); foreach ( $wrappers as $wrapper_key => $wrapper ) { if ( ! isset( $wrapper[ 'fields' ] ) ) { continue; } if ( isset( $select_fields_data[ $wrapper[ 'fields' ][ 0 ][ 'element_id' ] ] ) && ! empty( $select_fields_data[ $wrapper[ 'fields' ][ 0 ][ 'element_id' ] ] ) ) { $users = get_users(); if ( ! empty( $users ) ) { $new_options = array(); $user_names = array(); foreach( $users as $u ) { $new_options[] = array( 'label' => $u->user_login, 'value' => $u->user_login, 'limit' => '', 'key' => forminator_unique_key(), ); $user_names['options'] = $new_options; } $select_field = Forminator_API::get_form_field( $model_id, $wrapper['fields'][0]['element_id'], true ); if ( $select_field ) { Forminator_API::update_form_field( $model_id, $wrapper['fields'][0]['element_id'], $user_names ); $wrappers[ $wrapper_key ][ 'fields' ][ 0 ][ 'options' ] = $new_options; } } } } return $wrappers; },10,2); ?>
Thank you for the answer,
in the meantime i fixed it with this post:https://wpmudev.com/forums/topic/forminator-pro-i-would-like-to-include-two-images-files-in-my-form-and-automatically-attach-it-t/
- The solution is working only for the first selection field.