Skip to content

Instantly share code, notes, and snippets.

@sproutventure
Created January 26, 2011 04:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sproutventure/796249 to your computer and use it in GitHub Desktop.
Save sproutventure/796249 to your computer and use it in GitHub Desktop.
latest deal redirect.
function latest_deal_redirect( $redirect = null ) {
$latest_deal_qv = get_query_var( 'todays-deal' );
$latest_deal = ( $latest_deal_qv != '' ) ? $latest_deal_qv : $_GET['todays-deal'] ;
// redirect from homepage if cookie is set or we are using the todays-deal link
if( 1 == $latest_deal || ( is_home() && isset( $_COOKIE[ 'your-selected-location' ] ) ) ) {
$redirect = get_gbs_latest_deal_link();
} elseif ( is_home() && is_user_logged_in() ) { // redirect for logged in users
$redirect = get_gbs_deals_link();
}
if ( $redirect != null ) { // if we have something to redirect to let's do it.
wp_redirect( apply_filters( 'latest_deal_redirect', $redirect ) );
exit();
}
return;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment