• I need to get values from a multi select and display on author page. The user completes a form in the profile edit that includes mutli selects. The profile info then is displayed on the user’s author page. Data from all the other fields is displaying, however the multi select is not.

    My original code yielded the word “array” but I found ACF documentation that showed how to deal with multi selects. However, it didnt explain how to do it for an author page. Can anyone help?

    https://wordpress.org/plugins/advanced-custom-fields/

Viewing 12 replies - 1 through 12 (of 12 total)
  • I used

    <?php echo $curauth->profile-department-one; ?>

    within the loop, but no results (it either throws Array, or 0).

    There is nothing in the ACF documentation to help with this…

    Thread Starter jimario

    (@jimario)

    Hi Miguel,

    I found this but can’t seem to figure out how to integrate a call to get user id:

    /*
    *  Displaying multiple values
    */
    
    ?>
    <p>Colors: <?php echo implode(', ', get_field('page_layout')); ?></p>
    <?php

    The above code was found at: http://www.advancedcustomfields.com/resources/field-types/select/

    but you are correct. There is no documentation for displaying multi select values for user meta

    I tried that too, but threw an error. The guys at ACF are not responding either, so I am all at sea… One would think this is a common occurrence, and it merits some documentation… I am sure lots of people out there are in the same predicament…

    Thread Starter jimario

    (@jimario)

    I agree. I posted this help request and another one at the advancedcustomfields.com website. No response from anyone. It’s kind of strange. Glad that you responded. At least I’m not the only one finding this to be a head-scratcher.

    Ok, here is the solution (works outside the loop):

    <?php echo implode(', ', get_the_author_meta('your_custom_field')); ?>

    Thread Starter jimario

    (@jimario)

    Great! But I tried it and I’m not getting any values returned. It’s just blank. My custom field is a drop down select menu. My user has selected 3 out of 5 options in this menu and saved them. The above code doesn’t yield any result.

    Is it working for you?

    It is working perfectly for me, and it is the same kind of multiple-choice select.

    Maybe you haven’t preceded it by this?

    <?php
        $curauth = (isset($_GET['author_name'])) ? get_user_by('ID', $author_name) : get_userdata(intval($author));
        ?>
    Thread Starter jimario

    (@jimario)

    Ahhh, that might be the problem. I haven needed to use that one on this author.php page. I have around 400 plus fields. All work except the multis. Ill give it a try.

    Thread Starter jimario

    (@jimario)

    still getting blank. this what i have:

    <?php
        $curauth = (isset($_GET['author_name'])) ? get_user_by('ID', $author_name) : get_userdata(intval($author));
        ?>
    
    <div class="thelabels">Relatives who also experience Albinism	</div><div class="response"><?php echo implode(', ', get_the_author_meta('genetics_conditions_albinism_relatives')); ?></div>

    That’s about right, yes. You must have configured the custom field incorrectly in ACF. I can confirm the code works perfectly.

    Thread Starter jimario

    (@jimario)

    Not sure how a field could be configured incorrectly if it is showing up where it needs to show up.

    I’ve configured:
    Field Name: genetics_conditions_albinism_relatives
    Field Label: Relatives
    Field Type: Select
    Choices: name : name, etc.
    Allow Null?: None
    Select Multiple values: yes
    Conditional Logic: No

    Thread Starter jimario

    (@jimario)

    I created a different role type and assigned a single custom field of checkboxes to it. I then created an empty author template specifically for this tempalte containing only the following code:

    <?php
        $curauth = (isset($_GET['author_name'])) ? get_user_by('ID', $author_name) : get_userdata(intval($author));
        ?>
    
    <?php echo implode(', ', get_the_author_meta('test')); ?>

    On the backend I checked 3 out of 5 checkboxes. Still I get a complete blank.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘get results for multi select on author.php’ is closed to new replies.