Hello, I want to show the input checkbox in a personalized page as I have it in the user profile.
I made a group of custom fields called Subscriptions and a custom field called newsletter_preferences with the configuration as seen in the image:
config 1:
https://prnt.sc/hwambe
config 2:
https://prnt.sc/hwamkn
In the user prfile have this: https://prnt.sc/hwamwv
How print checkbox input complete in custom template linke this image: https://prnt.sc/hwanem
i need show all, checkbox input and label : https://prnt.sc/hwao1j
can you give a code snipped please?
Thanks for you help.
Firstly, your choices need to be like this
1 : Label for 1
Please note the space on both sides of the colon
2 you need to set the return value to return the value and the label in and array
Then you need to follow the documentation https://www.advancedcustomfields.com/resources/checkbox/
and you need to supply the user for the user that you want to show when your getting the field https://www.advancedcustomfields.com/resources/how-to-get-values-from-a-user/
$subs = get_field('field_name', $post_id);
if ($subs) {
?>
<ul>
<?php
foreach ($subs as $sub) {
?>
<li><?php echo $sub['value'],': ',$sub['label']; ?></li>
<?php
}
?>
</ul>
<?php
}