Skip to content

Instantly share code, notes, and snippets.

@miteshmap
Last active February 9, 2016 07:31
Show Gist options
  • Select an option

  • Save miteshmap/41f43f8e0105bcb07574 to your computer and use it in GitHub Desktop.

Select an option

Save miteshmap/41f43f8e0105bcb07574 to your computer and use it in GitHub Desktop.
Autocomplete uid to name and name to uid
<?php
function axelerant_custom_username_form($form, &$form_state) {
$default_user = user_load(3);
$form['name'] = array(
'#type' => 'textfield',
'#title' => t('Search for Contributor'),
'#autocomplete_path' => 'user/autocomplete',
'#default_value' => $default_user->name,
'#required' => TRUE,
);
return $form;
}
/**
* Implements hook_actions_delete().
*/
function axelerant_custom_username_form_submit($form, &$form_state) {
$name = trim($form_state['values']['name']);
$user = user_load_by_name($name);
// form_set_value($form['name'], $user->uid, $form_state);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment