Title: WP functions in &quot;side&quot; plugin files
Last modified: August 20, 2016

---

# WP functions in "side" plugin files

 *  [Igor Yavych](https://wordpress.org/support/users/flyerua/)
 * (@flyerua)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/wp-functions-in-side-plugin-files/)
 * Hey there. I need to use 2 WP functions outside of plugin’s main file, let’s 
   call this file functions.php . I need `is_user_logged_in()` and to get current
   user id which one get from global variable $current_user.
    What should I include
   or what else I should do to use these in files other than main plugin file? Thanks
   in advance

Viewing 1 replies (of 1 total)

 *  [Jay](https://wordpress.org/support/users/phyrax/)
 * (@phyrax)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/wp-functions-in-side-plugin-files/#post-2619353)
 * Flyer, the only way to do that is include wp-load.php… however, I think it’s 
   best to make your new file and include it in the main, that way you can use WordPress’
   functions without loading resources twice.
 * Example:
 *     ```
       <?php
            /* FILE: mainPluginFile.php */
            include('userFile.php');
   
            /* The rest of your code here */
       ?>
       ```
   
 *     ```
       <?php
           /* FILE: userFile.php */
           function userData(){
                /* Do your code here */
           }
   
           add_action('init', 'userData');
       ?>
       ```
   
 * You might want to also look into the [get_currentuserinfo](http://codex.wordpress.org/Function_Reference/get_currentuserinfo)
   function which you can wrap inside the is_user_logged_in method.

Viewing 1 replies (of 1 total)

The topic ‘WP functions in "side" plugin files’ is closed to new replies.

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 1 reply
 * 2 participants
 * Last reply from: [Jay](https://wordpress.org/support/users/phyrax/)
 * Last activity: [14 years, 2 months ago](https://wordpress.org/support/topic/wp-functions-in-side-plugin-files/#post-2619353)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
