I am trying to expose data fetched from remote API and stored to $user object. I have accomplished that with a custom views handler suggested in this post Custom views handler without table.
However, I need to add sorting and filtering, so any help will be great.
This is the custom views field handler code.
/**
* A handler to provide a field that shows the license type.
*
* @ingroup views_field_handlers
*/
class views_handler_apms_license extends views_handler_field {
function query() {
// do nothing -- to override the parent query.
}
function option_definition() {
$options = parent::option_definition();
// Override the alter text option to always alter the text.
$options['alter']['contains']['alter_text'] = array('default' => TRUE);
return $options;
}
function options_form(&$form, &$form_state) {
parent::options_form($form, $form_state);
// Remove the checkbox
unset($form['alter']['alter_text']);
unset($form['alter']['text']['#dependency']);
unset($form['alter']['text']['#process']);
}
function render($values) {
$user = user_load($values->uid);
if (isset($user->apms['userLicense'])) {
return $user->apms['userLicense'] ? t('BASIC') : t('FREE');
}
else {
return NULL;
}
}
}