• Resolved giampiero

    (@giampiero)


    Hi!

    I have extended the user options with some field, which I’m displaying in the author.php with the following pattern:

    $post_id = get_the_ID();
    $user_id = get_the_author_meta('ID', get_post_field('post_author', $post_id));

    $space_title = get_user_meta($user_id, 'space_title', true);
    ...

    # Display part follow this pattern:
    <?php if ($space_title) : ?>
    <p class="space_title">
    <?= $space_title ?>
    </p>
    <?php endif; ?>

    Now, I added the possibility to add a list of links through a repeatable text field, but I can’t figure out how to loop through the entries, because $space_links = get_user_meta($user_id, 'space_links', true); returns just a string of the first item submitted.

    A naif attempt to make it an array $space_links = array(get_user_meta($user_id, 'space_links', true)); had no good outcome.

    Any suggestion?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Paul Clark

    (@pdclark)

    See get_user_meta() — the third argument, $single should be true if it should return a single value, false if it should return an array of multiple values.

    $space_links = get_user_meta( $user_id, 'space_links', false );
    Thread Starter giampiero

    (@giampiero)

    Thank you very much, I totally ignored the meaning of the third value, and copy/pasted from the previuos lines.

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.