• Resolved theiATown

    (@theiatown)


    Hello,

    I am using the get_user_meta(‘$field’, ‘user_Id ‘) which retrieves information from a user profile and display its. What I am trying to do is turn this into a link. I have tried to use the “a href” approach, however it didn’t work.

    So for example, I have a user custom field called “state”. When I plug that into the get_user_meta(‘state’, ‘user_id’), the output for one user would be California. While the outlook for user 2 would be Ohio. I created two different pages for these “states” and I want the state to be a hyperlink directing to different pages based on the output name (e.g California).

    I also want to route to a subdomain(e.g. California.site.com) and NOT a site.com/Califonia.php page. Can someone please help.

    Thank you

Viewing 3 replies - 1 through 3 (of 3 total)
  • The syntax is
    <?php get_user_meta($user_id, $key, $single); ?>

    Just checking, you’re not describing the right order of parameters in your post:

    $user_id = whateverID; //use some function to grab the current userID that you're looking for
    $user_url = get_user_meta($user_id, 'user_url');
    $user_name = get_user_meta($user_id, 'display_name');
    $user_state = get_user_meta($user_id, 'state');
    
    <a href="<?php echo $user_url; ?>"><?php echo $user_name; ?> from <?php echo $user_state;  ?></a>

    *I have not tested this code, so user it as a guide and double check before implementing

    Let me know if that helps!

    Thread Starter theiATown

    (@theiatown)

    Thanks Tyler. I will give it a try, and let you know.

    Thread Starter theiATown

    (@theiatown)

    I was able to get it to work. Thanks Tyler.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How do I hyperlink a get_user_meta function.’ is closed to new replies.