require_once("clients/base/api/CurrentUserApi.php"); class CustomCurrentUserApi extends CurrentUserApi { public function registerApiRest() { //in case we want to add additional endpoints return parent::registerApiRest(); } // override the retrieveCurrentUser function public function retrieveCurrentUser($api, $args) { global $current_user; $current_user_results = parent::retrieveCurrentUser($api, $args); $user_data = $current_user_results['current_user']; // add custom fields here: $user_data['custom_field_c'] = $current_user->custom_field_c; return array('current_user' => $user_data); } }Then from within JavaScript you should be able to access your custom fields via:
app.user.get("custom_field_c");-Mark
Hello,
I have tried to get Full name of user using App.user.get
console.log(App.user.get("full_name"));
It giving me undefined in console.
Any suggestion for this?
One I get full name value then I can go for this solution for custom field.
Hi Hiren,
What is the error being received? App vs app can make a difference as JavaScript is a case sensitive language so these are seen as two separate objects.
When testing code from the JavaScript console, you have to use the global "App". From inside your code it is generally recommended to use "app" instead as it should have context and scope from within the code.
-Mark
Hi Hiren,
What is the error being received? App vs app can make a difference as JavaScript is a case sensitive language so these are seen as two separate objects.
When testing code from the JavaScript console, you have to use the global "App". From inside your code it is generally recommended to use "app" instead as it should have context and scope from within the code.
-Mark