Title: use shortcode in link?
Last modified: November 26, 2016

---

# use shortcode in link?

 *  [wheeleran](https://wordpress.org/support/users/wheeleran/)
 * (@wheeleran)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/use-shortcode-in-link/)
 * hi,
 * i thought i had this working but it seems not too, at least now that i’ve changed
   get_currentuserinfo to wp_get_current_user.
 * i want to use the plugin shortcode in a link, where ‘mysite.com/[client]’ redirects
   a logged in user to a specific page dependent on their username. the page name
   is the same as the username, so client1’s page is called ‘client1’, client2’s
   page is ‘client2’ and so on.
 * my function code for [client] is:
    global $userdata; wp_get_current_user(); echo(
   $current_user->user_login );
 * but this now redirects the link back to the site homepage.
    i would also want
   to make a link such as ‘mysite.com/[client]/payment’ but that presumes that i
   can even get the first link to work!
 * any assistance would be appreciated!
    thanks in advance.

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

 *  Thread Starter [wheeleran](https://wordpress.org/support/users/wheeleran/)
 * (@wheeleran)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/use-shortcode-in-link/#post-8483403)
 * excuse me; _this_ works:
    global $userdata; get_currentuserinfo(); echo( $userdata-
   >user_login );
 * but wp_get_current_user does not…?
 *  Plugin Author [Michael Simpson](https://wordpress.org/support/users/msimpson/)
 * (@msimpson)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/use-shortcode-in-link/#post-8483718)
 * You are not capturing the return value in a variable. Try this:
 *     ```
       $current_user = wp_get_current_user();
       echo( $current_user->user_login );
       ```
   
 * [https://codex.wordpress.org/Function_Reference/wp_get_current_user](https://codex.wordpress.org/Function_Reference/wp_get_current_user)
 *  Thread Starter [wheeleran](https://wordpress.org/support/users/wheeleran/)
 * (@wheeleran)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/use-shortcode-in-link/#post-8484371)
 * thank you, Michael. this works. so did the old get_currentuserinfo, but it being
   deprecated bothered me, so it’s nice to update it. thanks very much for your 
   help!

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

The topic ‘use shortcode in link?’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/add-actions-and-filters_ffffff.svg)
 * [Add Shortcodes Actions And Filters](https://wordpress.org/plugins/add-actions-and-filters/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/add-actions-and-filters/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/add-actions-and-filters/)
 * [Active Topics](https://wordpress.org/support/plugin/add-actions-and-filters/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/add-actions-and-filters/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/add-actions-and-filters/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [wheeleran](https://wordpress.org/support/users/wheeleran/)
 * Last activity: [9 years, 5 months ago](https://wordpress.org/support/topic/use-shortcode-in-link/#post-8484371)
 * Status: not resolved