Hi, does anyone know how to do this?
On a site where it's important that members work on their user profile, you don't want the edit tab to be the only pointer to where a user can fill in their profile.

The url of the profile edit page is user/uid/edit, uid being the unique user id, so you can't just put a static url in your menu to the profile edit page.
Is there a way to link directly to the edit page in page.tpl.php or in the menu module?

Thanks in advance,
JR

Comments

If you want to put fixed link in page.tpl.php you can use this syntax:

<?php
print l(t('edit profile'), "user/{$GLOBALS['user']->uid}/edit");
?>

If you will use Drupal menu system you can create node (page, story) with input format PHP and to body write this:

<?php
drupal_goto
('user/'.$GLOBALS['user']->uid.'/edit');
?>

After you will create menu item with url of the created node. When somebody will click on the link he will be redirected to edit his profile.

thats awesome thanks.

an image instead of the "edit user" text?

Look for the link command of drupal. http://api.drupal.org/api/5/function/l
This is how l() is defined:

l($text, $path, $attributes = array(), $query = NULL, $fragment = NULL, $absolute = FALSE, $html = FALSE)

You see l() has more arguments than just 2. Last argument has to be TRUE. Then the text is interpreted as HTML and you can put an img-tag into instead of the text.

;)

My only remaining issue is creating hover text for the image. Here is my code. Can you advise?

<?php
print l('<IMG src=" /irp/themes/mydrupal/mydrupal1/icons/tag_blue_edit.png" align=right>',
"user/{$GLOBALS['user']->uid}/edit", array('title' => 'edit user'), NULL, NULL, FALSE, TRUE);
?>

<?php
print l('<IMG name=mypic id=mypic src="/irp/themes/mydrupal/mydrupal1/icons/tag_blue_edit.png" align=right
onMouseOver="this.src=otherpic.png" onMouseOut="this.src=tag_blue_edit.png">'
,
"user/{$GLOBALS['user']->uid}/edit", array('title' => 'edit user'), NULL, NULL, FALSE, TRUE);
?>

Substitute paths.
Look for onMouseOver and onMouseOut in HTML/Javascript documentation, if theres something wrong.

;)

This page is a little out of date -- if you're using D6

In template.php:

function mytheme_preprocess_page(&$vars) { //See http://api.drupal.org/api/function/template_preprocess_page/6
  global $user;
  //other stuff...
  $vars['edit_profile_link'] = $user->uid ? l(t("Edit my profile"), "user/" . $user->uid . "/edit") : NULL;
}

In page.tpl.php:

if($edit_profile_link) {
  print $edit_profile_link;
}

Thank you for your update for D6. Is there a way to link to the page in the menu system.

i would like to have this to. a menupoint to the profile edit form
how i can do that ?

<?php
drupal_goto
('user/'.$GLOBALS['user']->uid.'/edit');
?>

this code doesn't work...

Create a node (page/story) with Input format filter set as PHP code and copy the following code.

<?php
drupal_goto
('user/'.$GLOBALS['user']->uid.'/edit');
?>

The menu link to latter created node should redirect to the user edit page.:):)

Thanks!

@entendu http://drupal.org/comment/reply/102162/2431068#comment-2431068
if you add a preprocess_page function then edit_profile_link will work in the page.
i tentatively changed function MYTHEME_template_preprocess_block(&$variables) to make the variable available in a block but it doesn't print anything...

This can be done via code in a custom module e.g.: (search for module creation guide for how to set up a module and then put this in the .module file)

<?php
function MODULENAMEHERE_menu() {
 
$items = array();
 
$items['user/edit-my-profile'] = array(
   
'title'            => 'Edit Profile',
   
'description'      => '',
   
'page callback'    => 'MODULENAMEHERE_edit_my_profile',
   
'access arguments' => array('access content'),
   
'type'             => MENU_NORMAL_ITEM,
    );
  return
$items;
}
function
MODULENAMEHERE_edit_my_profile() {
  global
$user;
 
drupal_goto('user/'.$user->uid.'/edit');
}
?>

Then when you enable the module the link will show up in the Navigation menu for you to with as you please.

Thanks it works.

You can do that without redirect, using the same core user module menu options and functions:

<?php
function MYMODULE_menu() {
 
$items = array();
 
$items['user/edit'] = array(
   
'title'            => 'Edit Profile',
   
'description'      => 'Edit own profile',
   
'page callback'    => 'MYMODULE_user_edit',
   
'access callback'  => 'MYMODULE_user_edit_access',
   
'type'             => MENU_LOCAL_TASK,
   
'file'             => 'user.pages.inc',
   
'file path'        => 'modules/user'
 
);
  return
$items;
}
function
MYMODULE_user_edit() {
  global
$user;
 
$account = user_load($user->uid);
  return
drupal_get_form('user_profile_form', $account);
}
function
MYMODULE_user_edit_access(){
  global
$user;
  return
user_edit_access($user);
}
?>

short information: this has to be a module, can't go in a theme (template.php)

follow me on Twitter: https://twitter.com/ABaumeier

The me module creates a way to do this easy. I haven't done full testing to see if it was the culprit, but I was having some issues with my content profile bouncing back and forth between two redirects and I'm thinking it was the me module, but again not sure. But it does provide an easy solution to this issue.

http://drupal.org/project/me

I just looked at views and see where the url is linked.

Then make a link in menu.

For example, I wanted edit tab say Edit Profile Info...
I tried using user/[user-id]/edit, user/%uid/edit....etc.

Finally, for this particular function on tab, it was user/%/edit...

So I made a menu item and linked it to user/%/edit... now they go directly to their Account Info and all Profile info they need to edit ;)

I'm getting this error message when I try to give a menu link that path:

The path 'user/%/edit' is either invalid or you do not have access to it.

Huh?

I think it worked for Nonnie because they had made a custom page at user/%/edit

can also try http://drupal.org/project/menu_token module
should also do what you are looking for