Pergunta

I feel like this should be simple, but I'm having a hard time making it happen.

I want to set up a menu item through Drupal's menu system (through the interface, not in a module). I simply want this menu item to go straight to user/[uid]/edit BUT I want the path to display as my-account

I have tried using hook_url_outbound_alter and inbound_alter to rewrite the my-account path, but then when I try to set up the menu item, Drupal rewrites the path for the menu item as /user/1/edit (since I'm logged in as the admin user when I set up the menu).

How do I do this?

Foi útil?

Solução

I was hoping for a solution that didn't require a custom module, but this is what I ended up doing:

function user_edit_menu() {
    global $user;
    print_r($user);
    $items['my-account'] = array(
        'page callback' => '_user_edit_page_callback',
        'access callback' => '_user_edit_access_callback',
        'file' => 'user.pages.inc',
        'file path' => drupal_get_path('module', 'user')
    );

    return $items;
}

function _user_edit_page_callback() {
    global $user;
    return drupal_get_form('user_profile_form', $user);
}

function _user_edit_access_callback() {
    global $user;

    return user_edit_access($user);
}

Now I can just point my menu item to my-account and get the user edit form.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top