I've got a directory within my wordpress directory for many template application


During my application i would like the wordpress current user id

I can do that in a single page however in another I recieve a mistake

This is exactly what I'm doing to obtain the user id:

require_once( '/../../wp-load.php' );
global $current_user;
$user_id = $current_user->ID;

however i have an error about this line

 require_once( '/../../wp-load.php' );

The mistake states

 File does not exist: D:/programming/apacheWWW/wordpress/jtpc/ajaxHandlers/wp-admin, referrer: http://localhost/wordpress/?page_id=23

what dose he wants using the wordpress-admin , and why he's searching for it within the wrong directory , It's suppose to become under


It's employed by one page, (I'm uploading file and developing a directory with this user id)

as well as the other page I send an ajax request to remove files by user request so I have to id again, but there he throws the mistake

You might want to try among the following two lines:

require_once STYLESHEETPATH . '/wp-load.php';


require_once TEMPLATEPATH . '/wp-load.php';

There's a small distinction between the STYLESHEETPATH constant and also the TEMPLATEPATH constant. If you're creating a child theme, STYLESHEETPATH would be the child theme path, while TEMPLATEPATH would be the parent theme path.

This really is ways you can get current user:

global $current_user;
$current_user = wp_get_current_user();

Next, you should use $current_user->ID in which you want.

More Information:

ok got i working i put

  require_once( '/../../wp-load.php' );

towards the top of the page and never within the function