• Hi,

    To help users I write how-to.
    Sometimes, to make it easier, I include hyperlinks to pages/functionalities.
    But sometimes I need the current user’s id to build the url.

    For example. On a website I use ultimate Member.
    In my advises, I suggest users to update their profile (the Ultimate Member’s profile).
    So I would like to add in my advises an hyperlink the profile page to make it easier.
    But the URL looks like that: https://www.mywebsite.com/user/wp_user_id/

    So how can I include the current user’s id in an hyperlink in a post?

    Can we use any kind of BBcode, short code, html/php code, etc.?
    Or does an extension provide this possibility?

    Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Phil

    (@owendevelopment)

    Hi,

    Assuming the plugin uses standard WordPress users, you could try this in your template:

    
    <?php $current_user = wp_get_current_user(); ?>
    <a href="https://www.mywebsite.com/user/<?php echo $current_user->ID; ?>">Link to page with user URL</a>
    
    Thread Starter ftpwp

    (@ftpwp)

    Hi @owendevelopment,

    Thanks for your answer!
    Sorry, I didn’t had any email notification of your reply.

    <?php $current_user = wp_get_current_user(); ?>
    <a href="https://www.mywebsite.com/user/<?php echo $current_user->ID; ?>">Link to page with user URL</a>

    Hum… doesn’t work.
    If I copy/paste the code in a post in the Classic Editor > Text tab and Publish, nothing is displayed :-/

    Thread Starter ftpwp

    (@ftpwp)

    Any idea? Anyone?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to set in a post an hyperlink using the current user id?’ is closed to new replies.