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.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.