Skip to content

Instantly share code, notes, and snippets.

@nielsnuebel
Created April 5, 2018 11:37
Show Gist options
  • Save nielsnuebel/e7d96df2332f812ad7fe1c1d06fe6a11 to your computer and use it in GitHub Desktop.
Save nielsnuebel/e7d96df2332f812ad7fe1c1d06fe6a11 to your computer and use it in GitHub Desktop.
protected function _getUserData()
{
if ($this->user->guest)
{
return;
}
// Get the dispatcher and load the user's plugins.
$dispatcher = \JEventDispatcher::getInstance();
PluginHelper::importPlugin('user');
$data = new \JObject;
$data->id = $this->user->id;
// Trigger the data preparation event.
$dispatcher->trigger('onContentPrepareData', array('com_users.profile', &$data));
if (isset($data->profile))
{
$this->user->profile = $data->profile;
}
$fields = FieldsHelper::getFields('com_users.user', $this->user, true);
// Adding the fields to the object
$this->user->customfields = new \JObject;
foreach ($fields as $key => $field)
{
$fieldname = $field->name;
$this->user->customfields->$fieldname = $field->value;
}
$params = new JRegistry;
$this->user->params = $params->loadString($this->user->params);
}
@nielsnuebel
Copy link
Author

nielsnuebel commented Apr 5, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment