How To / General

Getting moodle user id in joomla plugin

  • Mr Riddle
  • Topic Author
  • Offline
  • New Member
  • New Member
More
5 years 1 month ago #1 by Mr Riddle
Getting moodle user id in joomla plugin was created by Mr Riddle
Hi!
I'm trying to write module for Joomla. How can I get current logged in moodle user id?

With this:
Code:
JFactory::getUser(); $user_id = $user->id;
I'm getting Joomla user id witch is not equal to the moodle id of the same user :/

I was also trying this:
Code:
require_once(JUri::root()."/baza/config.php") ; require_login(); $usr_id = $USER->id
But I'm getting blank page.

Is it any simple way to get moodle user id in joomla module?

Please Log in or Create an account to join the conversation.

More
5 years 1 month ago #2 by Antonio Durán
Replied by Antonio Durán on topic Getting moodle user id in joomla plugin
Hi.
You can use a Joomdle call for that:
$moodle_user_id = JoomdleHelperContent::call_method ("user_id", $username);

You'll need to include the helper file to use the method.

Bear in mind that this is a web service call to Moodle, so it will use a HTTP connection each time.

Please Log in or Create an account to join the conversation.