Hello!
I'm sorry if my question in incorrect forum category.
I write web-app and I need to use drupal (version 7.39) users from my site. To they can log in my app if they have account on my site. I want get list of users to register their accounts in my app.
How can I do it?
Now, I try so:

		include_once('config.php');
		define('DRUPAL_ROOT', dirname(getcwd()));
		require_once DRUPAL_ROOT.'/includes/bootstrap.inc';
		drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
		global $user;
		$user_fields = user_load($user->uid);
		$firstname = $user_fields->field_firstname['und']['0']['value'];
		$lastname = $user_fields->field_lastname['und']['0']['value'];
		echo  t("Welcome: " . $firstname. ' ' . $lastname) ; 

But it nothing output on page. My app located in inner folder of drupal root (drupal_folder/my_app_folder).
What I do incorrectly?
P.S. Sorry for my English...

Comments

rhuffstedtler’s picture

The difference is that the original developer did a db_query for the user information rather than using user_load(). I don't see anything obviously wrong in what you have.

Are you certain that the $user global is initialized and has a valid uid set at the time that you are calling it?

Since you have bootstrapped Drupal, you should be able to log things with watchdog. For something like this, I might be inclined to fire up Xdebug and step through it.

ghostman2013’s picture

Thank you very much! Now, I at least will sure that code is correct. Then I'll install XDebug, just I don't know that it have this debugger.