Support

Account

Home Forums General Issues Choose ACF relationship field at registration form Reply To: Choose ACF relationship field at registration form

  • i have put this code inside the form tag

    <p class="input_container">
                            <label for="related_study_paths"><?php _e('Related Study Paths'); ?></label>
                            <?php
                            // Retrieve the current user's selected study paths
                            $selected_study_paths = get_field('related_study_paths', 'user_' . get_current_user_id());
    
                            // Render the ACF Relationship field choices
                            acf_form(array(
                                'post_id' => 'user_' . get_current_user_id(),
                                'post_title' => false,
                                'form' => false,
                                'field_groups' => array('group_XXXXXXXXX'), // Replace with your field group key
                                'fields' => array('related_study_paths'), // Replace with your field name
                                'return' => false,
                                'submit_value' => false,
                                'values' => array('related_study_paths' => $selected_study_paths), // Pass the selected choices
                            ));
    
                            if ($selected_study_paths) {
                                echo '<ul>';
                                foreach ($selected_study_paths as $study_path) {
                                    echo '<li>' . get_the_title($study_path) . '</li>';
                                }
                                echo '</ul>';
                            }
                            ?>
                        </p> 

    It does output a form field with a search bar but it does not have anything inside it to select from.