Get user information in javascript file without adding user profile block

Get user information in javascript file without adding user profile block

by yasha jain -
Number of replies: 3

How i can get user email id or other information in javascript without adding  user profile block in admin account. Is there any way to do this. 

Average of ratings: -
In reply to yasha jain

Re: Get user information in javascript file without adding user profile block

by Davo Smith -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

When you initialise your javascript, pass the relevant details into it.

e.g. if you are using the recommended AMD module method of loading javascript:

$PAGE->requires->js_call_amd('plugin/jsmodule', 'init_function', array($userdetails));


In reply to Davo Smith

Re: Get user information in javascript file without adding user profile block

by yasha jain -
Actually  i am not using AMD module  method of loading javascript. I upload my java script in Additional Html option.
In reply to yasha jain

Re: Get user information in javascript file without adding user profile block

by Davo Smith -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
I'm not aware of any way to pass information into the JavaScript when adding it that way. I suggest that if your requirements involve needing access to extra data, then you should look at writing a full plugin.