Title: Calling the User ID for javascript
Last modified: August 20, 2016

---

# Calling the User ID for javascript

 *  Resolved [smpayne2](https://wordpress.org/support/users/smpayne2/)
 * (@smpayne2)
 * [14 years, 7 months ago](https://wordpress.org/support/topic/calling-the-user-id-for-javascript/)
 * I have been blessed with a javascript/PHP plugin that will add the user_id to
   the end of external links. One small problem: I have to update the “define” line
   with calling the logged in user’s ID #. Does anybody know how I tell it to define
   that paramater as the user ID?
 * (noncoder here)
 * _[Code moderated as per the [Forum Rules](http://codex.wordpress.org/Forum_Welcome#Posting_Code).
   Please use the [pastebin](http://wordpress.pastebin.com/)]_

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

 *  Thread Starter [smpayne2](https://wordpress.org/support/users/smpayne2/)
 * (@smpayne2)
 * [14 years, 7 months ago](https://wordpress.org/support/topic/calling-the-user-id-for-javascript/#post-2336438)
 * Does this look right?
 *     ```
       <?php
           wp_get_current_user();
           echo 'User ID: ' . $current_user->ID . '<br />';
       ?>
   
       define( 'EXT_LINK_PARAMS', 'ul=$current_user' );
       ```
   
 *  [Fiaz Husyn](https://wordpress.org/support/users/fiazhusyn/)
 * (@fiazhusyn)
 * [14 years, 7 months ago](https://wordpress.org/support/topic/calling-the-user-id-for-javascript/#post-2336517)
 *     ```
       <?php
           wp_get_current_user();
           $user_id = $current_user->ID;
           echo 'User ID: '.$user_id.'<br />';
                   $ext_link_param = 'ul='.$user_id;
   
       define( 'EXT_LINK_PARAMS', $ext_link_param );
       ?>
       ```
   
 *  Thread Starter [smpayne2](https://wordpress.org/support/users/smpayne2/)
 * (@smpayne2)
 * [14 years, 7 months ago](https://wordpress.org/support/topic/calling-the-user-id-for-javascript/#post-2336538)
 * Thank you!

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

The topic ‘Calling the User ID for javascript’ is closed to new replies.

## Tags

 * [javascript](https://wordpress.org/support/topic-tag/javascript/)

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 3 replies
 * 2 participants
 * Last reply from: [smpayne2](https://wordpress.org/support/users/smpayne2/)
 * Last activity: [14 years, 7 months ago](https://wordpress.org/support/topic/calling-the-user-id-for-javascript/#post-2336538)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
