i have problem to get a value from my custom user field i read this issue https://github.com/signalpoint/DrupalGap/issues/641 but still confused me i just can get the Drupal.user.uid or Drupal.user.name only as an object. ex i have the custom field value :

$account->field_nama_lengkap['und'][0]['value'];

so how to get that value in drupalgap i tried to get with "Drupal.user.field_nama_lengkap" but i get undefine

thank

Comments

imunk created an issue. See original summary.

tyler.frankenstein’s picture

Category: Task » Support request

This comment has the code you need to put in a custom Drupal module: https://github.com/signalpoint/DrupalGap/issues/641#issuecomment-150949553

Once you do that, the Drupal.user object will be fully loaded and available to you in DrupalGap, after the System Connect call.

imunklovarian’s picture

there are 2 comments whic one

/**
 * Implements hook_services_request_postprocess_alter().
 */
function my_module_services_request_postprocess_alter($controller, $args, &$result) {
  if ($controller['callback'] == '_system_resource_connect') {
    global $user;
    if ($user->uid) {
      $account = user_load($user->uid);
      unset($account->pass);
      $result->user = $account;
    }
  }
}

or

/**
 * Implements hook_services_request_postprocess_alter().
 */
function my_module_services_request_postprocess_alter($controller, $args, &$result) {
  if ($controller['callback'] == '_user_resource_retrieve') {
    $result->my_module = array('foo' => 'bar');
  }
}

and how to check that module working and call it in drupalgap ??
tyler.frankenstein’s picture

When you follow the link, Github/your-browser should auto scroll you to the comment that I linked directly, issue comment 150949553

If not, it's the first chunk of code mentioned in your comment above.