Username Password
Bookmark and Share


UPDATE: Macro now has the option to check the HTTP_REFERER, which makes it possible redirect only once a visit.

Macro for redirecting certain groups to another page.

One of our clients use it for their welcome page. Visitors get a generic welcome page, registered users a customized personal page.

^RedirectGroup(Registered Users,/mypage);
This redirect all registered users to /mypage

^RedirectGroup(Registered Users,/mypage, check_referer);
This redirects all registered users who weren't on the site already to /mypage.

Note 1#: Put this macro in the Page Meta Tags section.
Note 2#: The macro works only when Admin mode is switched off.
Note 3#: When using check_referer make sure page caching is switched off otherwise it won't work.
Note 4#: When check_referer is on, the macro redirects only one time a visit.

Place in your /lib/WebGUI/Macro
directory, add RedirectGroup => RedirectGroup, \
to the macros section of /etc/WebGUI.conf,
and restart your webserver.

System RequirementsPlease be advised: this contribution was tested with something older than WebGUI 7.5. When this contribution was uploaded there was no field for the author to fill out regarding it's requirements.
4andreasG: "
i think it must be
 RedirectGroup => RedirectGroup, \

WebGUI worldwide Germany
4len: "
You're right. Thanks for pointing it out. I've changed it.

Len Kranendonk
3jigou: "
Hi, Len.

I'm currently running v6.2.7 of WebGUI.

I'm getting an error in my WebGUI log when it tries to process RedirectGroup: Undefined subroutine &WebGUI::Privilege::isInGroup called at c:/data/WebGUI/lib/WebGUI/Macro/ line 24

I'm guessing that the isIngroup function is no longer alive in the current version of WebGUI?

4timhobbs: "
I installed this macro and found that I kept getting redirected to the same page over and over again.  I made the following change to the code:

 if (    WebGUI::Privilege::isInGroup($groupId) && !$session{var}{adminOn} &&
            (! $param[2] || $session{env}{HTTP_REFERER} !~ /$session{env}{SERVER_NAME}/i ) && $param[1] ne $session{env}{REQUEST_URI})
                return '<META HTTP-EQUIV="refresh" content="0;URL='.$param[1].'">';

and this seemed to fix the problem.  Hope this helps.

LinksNo Support Offered
Statistics Downloads: 735
Views: 7756
Rating: 4
Updated: 8/12/2005
Keywords macros
NavigationBack to the Bazaar
© 2022 Plain Black Corporation | All Rights Reserved