News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Adding member ID to url

Started by gasman, January 13, 2011, 07:26:29 PM

Previous topic - Next topic

gasman

I a trying to add a new button to the menu, do give  direct link to the Subscriptions area. (SMF 2.0 RC4)


I have added the following code to the Subs.php file:





         'subscriptions' => array(
            'title' => 'Subscriptions',
            'href' => $scripturl . '?action=profile;area=subscriptions;u=',
            'show' => !$user_info['is_guest'],
            'sub_buttons' => array(
            ),
         ),





My problem is that I need to insert the current member's ID after the "u="


I have tried $context['id'] but it returns nothing.


Can anyone tell me the global variable for the current member's ID?

[/code]

Kays

Hi, you use either $context['user']['id'] or $user_info[/id']


         'subscriptions' => array(
            'title' => 'Subscriptions',
            'href' => $scripturl . '?action=profile;area=subscriptions;u=' . $user_info['id'],
            'show' => !$user_info['is_guest'],
            'sub_buttons' => array(
            ),
         ),

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

gasman

Many thanks - worked beautifully.

Sev-M.C.

i was trying to make  a custom href in the index.template.php that contains the memberurlbut guive me this error:

Href: <li><a href="', $scripturl . '?blog='.$user_info['id'],"></li>

Error: Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in index.template.php on line 538,

but when i try with  ',' or ';'  it returns nothing.

Joker™

Quote from: sevrva22 on January 20, 2011, 10:01:58 PM
i was trying to make  a custom href in the index.template.php that contains the memberurlbut guive me this error:

Href: <li><a href="', $scripturl . '?blog='.$user_info['id'],"></li>

Error: Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in index.template.php on line 538,

but when i try with  ',' or ';'  it returns nothing.
Try this as

<li><a href="', $scripturl . '?blog;u=' . $user_info['id'] . '"></li>

and next time please open a separate thread for your questions :).
Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

Sev-M.C.

mmm it doesn`t work :( it just gives me the following URL: http://musicommunity.org/index.php?blog;u=

Does i open a new threat for this problem?

Joker™

Umm try this code

echo '<li><a href="', $scripturl . '?action=blog;u=' . $user_info['id'] . '">','your text here','</li>';


also put $user_info in global.
Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

Masterd

You can also use $memID for this.

Sev-M.C.

#8
Perfect!  ;D Solved


Advertisement: