Title: Get Variable to link
Last modified: August 22, 2016

---

# Get Variable to link

 *  [Ch3d](https://wordpress.org/support/users/ch3d/)
 * (@ch3d)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/get-variable-to-link/)
 * Hi there !
 * I got a little problem… Let me explain.
 * I create manually for each user of my website a private page that he and only
   he can see.
 * The addresses of the pages are created as is “[http://exemple.fr/private/didier&#8221](http://exemple.fr/private/didier&#8221);
   Didier is the name/username of the user.
 * I wish I could include a button on the site (in a page) that will redirect the
   person who clicks a link:
 * “[http://exemple.fr/private/$username&#8221](http://exemple.fr/private/$username&#8221);,“
   username” is replaced by usersame user who clicked.
 * So if Didier click on the button: “[http://exemple.fr/private/$username&#8221](http://exemple.fr/private/$username&#8221);
   
   the redirect link will be for him “[http://exemple.fr/private/didier](http://exemple.fr/private/didier)“
   and if Geraldine clicks this link, it will be redirected to “[http://exemple.fr/private/geraldine.&#8221](http://exemple.fr/private/geraldine.&#8221);
 * So I know that in theory i should create a function in PHP that will get $username(
   or equivalent) in the database and associate it with a keyword (or shortcode?)
   So in theory it would give something like :
 * [username] = Retrieve: “BDDUser/$username”
 * In theory, huh, I’m not a programmer I just have some basics bases. p
 * And then if I make a link to an image, or other button on the site that would“
   [http://exemple.fr/private/%5Busername%5D&#8221](http://exemple.fr/private/%5Busername%5D&#8221);
   still theoretically it should give the function I want.
 * The trouble is that, as I said, I know not program and I have no idea what to
   do so rather than do something stupid I just ask a boost!
 * I hope I was clear enough!
    Thank you! 🙂

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

 *  [Adam Czajczyk](https://wordpress.org/support/users/ambiantepl/)
 * (@ambiantepl)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/get-variable-to-link/#post-5768995)
 * Hi ch3d,
 * Take a look here: [http://codex.wordpress.org/Function_Reference/get_currentuserinfo](http://codex.wordpress.org/Function_Reference/get_currentuserinfo)
 * Example:
 * `<a href="http://exemple.fr/private/<?php echo $current_user->user_login;?>">
   Click here</a>`
 * Instead of ‘->user_login’ you may use ‘->display_name’, depending on which one
   you’ve used to create site. Anyway, that link from above should give you everything
   you need to know.
 * Good luck!
    A.
 *  Thread Starter [Ch3d](https://wordpress.org/support/users/ch3d/)
 * (@ch3d)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/get-variable-to-link/#post-5769138)
 * Thank a lot, I forgot to answer but you saved my life ! Ahah.
 *  [Adam Czajczyk](https://wordpress.org/support/users/ambiantepl/)
 * (@ambiantepl)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/get-variable-to-link/#post-5769144)
 * Not a problem, I’m happy for you 🙂

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

The topic ‘Get Variable to link’ is closed to new replies.

## Tags

 * [account](https://wordpress.org/support/topic-tag/account/)
 * [Customer](https://wordpress.org/support/topic-tag/customer/)
 * [link](https://wordpress.org/support/topic-tag/link/)
 * [Private page](https://wordpress.org/support/topic-tag/private-page/)
 * [user](https://wordpress.org/support/topic-tag/user/)
 * [variable](https://wordpress.org/support/topic-tag/variable/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 2 participants
 * Last reply from: [Adam Czajczyk](https://wordpress.org/support/users/ambiantepl/)
 * Last activity: [11 years, 3 months ago](https://wordpress.org/support/topic/get-variable-to-link/#post-5769144)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
