Home Forums ACF PRO How to get fields from another group by using Checkbox


How to get fields from another group by using Checkbox

  • I am a beginner of wordpress and ACF, and I have a question that I think it’s complicated and needs to customize the codes.

    There are two pages, one is AUTHOR page with name, phone number, email, intro, avatar, etc., so I add those fields in the “author” group of fields and it shows everything perfectly in the author page. (There will be many authors.)

    Another page is SERVICE page. There is a section in this page that I need to get some authors’ info in order to show these people could provide you the specific service.

    In my mind I hope there’s checkbox in the “service” group of fields which users check the names and it will show those authors’ info without having to type them again and again in different service pages.

    There’s lots of challenges: how to get the fields in another group of fields? and how to make it possible to show a stream of html codes when I just check the checkboxs in the ACF field?

    Here is the codes I have now, but sorry it’s not complete. For now I still cannot get the fields in “author” group (which ID is 114) coz I don’t know how to structure them together:

    <div class="service_member">
         <a href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ); ?>">
           <?php $user_id = get_the_author_meta('ID'); $image = get_field('lawyer_image_sm', 'user_'.$user_id);
               if( !empty($image) ): ?>
               <img class="img-circle img-responsive img-center" src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" style="float:left;">
            <?php endif; ?>
            <span class="service_name"><?php the_author(); ?></span>
         <div class="service_info" style="clear:both;">
           <br><span>Tel</span>  <?php $user_id = get_the_author_meta('ID'); the_field('lawyer_tel', 'user_'.$user_id); ?>      
           <br><span>Mail</span>  <?php $user_id = get_the_author_meta('ID'); the_field('lawyer_email', 'user_'.$user_id); ?>

    The attached image is the capture of the checkbox field in the “service” group of fields, should I put any other codes here?
    Thank you in advance for a great great great help!!!!

  • Instead of using a checkbox field try using a user field if. This creates a user relationship to users that allow you do select the users. Then on the service page you can get the values in the user relationship field, and this will let you get the values from the user.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.