Last active
September 20, 2015 13:17
-
-
Save johnennewdeeson/298a6e587414078b5505 to your computer and use it in GitHub Desktop.
Drupal 7 make /user go to the user edit form when logged in for sites that don't have user profile pages and you don't want a full page view of a user.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Implements hook_menu_alter(). | |
*/ | |
function mymodule_menu_alter(&$items) { | |
if (isset($items['user/%user'])) { | |
// Turn user/%user into an edit form callback rather than view. | |
$items['user/%user']['page callback'] = 'drupal_get_form'; | |
$items['user/%user']['page arguments'] = array('user_profile_form', 1); | |
$items['user/%user']['access callback'] = 'user_edit_access'; | |
$items['user/%user']['access arguments'] = array(1); | |
$items['user/%user']['file'] = 'user.pages.inc'; | |
$items['user/%user']['title callback'] = 'user_page_title'; | |
$items['user/%user']['title arguments'] = array(1); | |
$items['user/%user']['menu_name'] = 'navigation'; | |
// Get rid of user/[uid]/view, replacing it with the edit. | |
$items['user/%user/edit'] = $items['user/%user/view']; | |
unset($items['user/%user/view']); | |
$items['user/%user/edit']['title'] = 'Edit'; | |
} | |
} | |
/** | |
* Implements hook_admin_paths(). | |
*/ | |
function mymodule_admin_paths() { | |
return array( | |
'user' => TRUE, | |
'user/*' => TRUE, | |
'user/*/edit' => TRUE, | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment