"moodle_user_get_users_by_id" Parameters problem

"moodle_user_get_users_by_id" Parameters problem

by Ivan Aibar Romero -
Number of replies: 6

Hi!

I'm developing an Android app and when I retrieve all the data that the webservice have sent to me, the parameter "email" is always null except when i retrieve the data from the admin (prety weird).

Any way to solve that problem? Thanks.

Average of ratings: -
In reply to Ivan Aibar Romero

Re: "moodle_user_get_users_by_id" Parameters problem

by Jérôme Mouneyrac -

Hi Ivan,

the web service function matches Moodle permission. So if your user is not able to see a user email in Moodle, the web service function will not return it too.

Cheers,
Jerome 

In reply to Jérôme Mouneyrac

Re: "moodle_user_get_users_by_id" Parameters problem

by Ivan Aibar Romero -

But I can see every user's email in Moodle. Even I create users with the "moodle_user_create_users" (email required to create a user).

Maybe I do something wrong, but it's pretty weird that I can retrieve every parameter except the email.

In reply to Ivan Aibar Romero

Re: "moodle_user_get_users_by_id" Parameters problem

by Netram Dhakar -

Hi Ivan,

you have to investigate the following function in moodle/user/externallib.php for return parametrers

 public static function get_users_by_id($userids)

from line no. 382 to 290

Cheers

Netram Dhakar

In reply to Ivan Aibar Romero

Re: "moodle_user_get_users_by_id" Parameters problem

by Jérôme Mouneyrac -

Hi Ivan,

for the following actions:
a) see your own email
b) see other course participant's email
c) see other user's email

a) should be no problem as in Moodle anybody can see his email (by default). If it is, you can file a bug in the tracker.
b) and c) would depend of the capabilities. You most likely needs 'moodle/course:useremail' capability. But to summarize, if you can see someone else email in Moodle and not retrieve it by web service, then the web service function is buggy. In this case you can also write an issue.

When you file a tracker issue explain:

* what role (if you use a default one) you have
* what page you see someone else's email in Moodle
* what web service function is buggy (here moodle_user_get_users_by_id)

 

More info:
- an admin will always see other email's user.
- try get_course_user_profiles() to see other participant's email. I just checked the code and moodle_user_get_users_by_id() doesn't request a courseid. It means that you can not retrieve a course profile with this function. In Moodle you can retrieve system progfile or course specific profile. I think the name of this function (moodle_user_get_users_by_id) is not really appropriate.

 

 

In reply to Jérôme Mouneyrac

Re: "moodle_user_get_users_by_id" Parameters problem

by Ivan Aibar Romero -

Problem solved!

Email was only seen by other students (not the admin xD). Need to change that permission.

Thank you so much! ;)