6 * Plugin to provide an argument handler for a username
10 * Plugins are described by creating a $plugin array which will be used
11 * by the system that includes this file.
14 'title' => t("User: name"),
15 // keyword to use for %substitution
17 'description' => t('Creates a user context from a user name.'),
18 'context' => 'ctools_argument_user_name_context',
19 'placeholder form' => array(
20 '#type' => 'textfield',
21 '#description' => t('Enter the username of a user for this argument'),
26 * Discover if this argument gives us the user we crave.
28 function ctools_argument_user_name_context($arg = NULL, $conf = NULL, $empty = FALSE) {
29 // If unset it wants a generic, unfilled context.
31 return ctools_context_create_empty('user');
34 // We can accept either a node object or a pure nid.
35 if (is_object($arg)) {
36 return ctools_context_create('user', $arg);
39 $account = user_load_by_name($arg);
43 return ctools_context_create('user', $account);