ZenphotoCMS Forum
How to redirect in function of criteria - Printable Version

+- ZenphotoCMS Forum (https://forum.zenphoto.org)
+-- Forum: Support (https://forum.zenphoto.org/forum-1.html)
+--- Forum: General support (https://forum.zenphoto.org/forum-4.html)
+--- Thread: How to redirect in function of criteria (/thread-12227.html)



How to redirect in function of criteria - mric - 2015-07-30

Hello

When a user opens a link (page or album) I would like to check his rights and transparently redirect to a given page.

I idea is not to use nginx nor Apache redirect.

For instance

  • anonymous requests "/pages/members" and is redirected to "/pages/join"
  • logged in user requests "/pages/members" and is granted access

I would like to manage multiple rediect (not only "/pages/members").

Obviously the idea could be applied to any other criteria. For instance you logged 10 times today then are redirected to a given page.

I suspect I may use zp_register_filter/zp_apply_filter('getLink'...) for that and I also suspect the routing is done in zp-core/index.html
However I cannot figure out the details.

Thank you for your advice.




How to redirect in function of criteria - sbillard - 2015-08-10

There is a filter named load_theme_script that is called during the page loading process. It returns the script to be loaded. You can create a plugin which registers that filter.

Your handler for that filter would decide if a redirect should happen and return a different script and/or suitably modify global variables so that the loaded script does what you want.




How to redirect in function of criteria - acrylian - 2015-08-10

@mric: Sorry, somehow missed your post… The answer given above is the way to go.