Q:

Programming a custom redirect in a Drupal Site

I would like to know what is the best option to setup a Drupal redirect process that will look at the current time of day and then redirect the user to a page based on this information?
Since I have not had to do this before in Drupal, I'm looking for one or two suggestions on how to do this with the user starting the action from a menu item.
One thought I had is that I could create a page that is PHP content and determine the redirect there, but I'm unsure of how to code that in that location.
Also, I'm not sure if I've overlooked a module that could help with a conditional redirect or if all the references to form redirects might be applicable to what I'm trying to do.

A:

You could do something along the lines of this: 
function MYMODULE_menu() {

  $items['MYMODULE/whattodo'] = array(
    'title' => 'Where should I go now, George',
    'page callback' => 'MYMODULE_whattodo',
    'access callback' => TRUE, 
    'type' => MENU_CALLBACK,
  );

  return $items;
}

function MYMODULE_whattodo() {

  $foo= // code to get the current time of day in whatever form you want that matches the switch cases below

  switch($foo) {
     case // morning:
        drupal_goto(// page for the morning);
        break;
     case // afternoon:
        drupal_goto(// page for the afternoon);
        break;
     case // evening:
        drupal_goto(// page for the evening);
        break;
  }
}

which means when a user went to www.mysite.com/MYMODULE/whattodo, they would be redirected to whatever page you set up via drupal_goto()

