Profile as menu item

Has anyone added a menu item that links to the user's profile page? I can't figure out the url to add to the menu to go to a logged in users profile. Any suggestions? Thanks all.

  • Try...

    <a href="<?php echo $vars['url']; ?>profile/<?php echo $_SESSION['user']->username; ?>/"> Profile</a>

    Or with image...

    <a href="<?php echo $vars['url']; ?>profile/<?php echo $_SESSION['user']->username; ?>/"><img alt=""  src="<?php echo $vars['url']; ?>mod/mytheme/img/icons/profile.png" /></a>

     

  • Joel Iam not sure its working or not..

    with the help of this code we can get user name

    $context = elgg_extract('context', $vars, elgg_get_context());

    if (elgg_is_logged_in() && $context) {
        $username = elgg_get_logged_in_user_entity()->username;

    }

    Then you can assign menu link like this

    http://example.com/profile/$username

     

    :)

  • Actually what you're looking for is the elgg_register_menu_item() function

    if(elgg_is_logged_in()){

      elgg_register_menu_item('site', array(

        'name' => 'your_plugin_profile',

        'text' => elgg_echo('Profile'),

        'href' => elgg_get_logged_in_user_entity()->getURL()

      );

    }

  • Thanks everyone. That information worked. Cheers.