News:

Wondering if this will always be free?  See why free is better.

Main Menu

Using a condition check in a link -- how?

Started by Gobo, June 14, 2006, 03:46:13 AM

Previous topic - Next topic

Gobo

hi

I want to create a hyperlink which basically does the following:

When someone clicks on it, it checks:

- Is this person a guest or member?
>>>>If guest it takes them to Page X
>>>>If member it checks if they belong to the proper membergroup of not?
>>>>>>>If they do go to page Z
>>>>>>>If not go to page X

Is this possible with PHP?

And if yes can someone kindly code it for me? Thanks

jacortina

In the php which 'echo's out the link, you can use conditions so that different links are generated for different users.

It would be something like this, I believe:


    global $user_info;

    if ($user_info['is_guest']) echo '<a href="...Guest link target here...">Link Text</a>';
    elseif (in_array(#, $user_info['groups'])) echo '<a href="...Group# link target here...">Link Text</a>';
    else echo '<a href="...Default link target here...">Link Text</a>';


Replace the '#' in the 'in_array(#, $user_info['groups'])' with the number of the membergroup you want to supply with the particular link (you could actually have mulitple 'elseif' lines before the 'else' for default).

And put all the correct links in the 'a href="', of course.

Using the same Link Text, the link would appear the same to all, but clicking would take user to the appropriate place.

Gobo

wow thanks :D

I'm gona try it out very soon :D

Thank you very very much :D

JayBachatero

Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

Gobo

thanks jay :D

Nice to see you again :D hope you are in the best of health :D

JayBachatero

Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

Advertisement: