Last active
September 29, 2017 17:28
-
-
Save alicolville/adad1a58ce21bc78c932d8d150d6cf6b to your computer and use it in GitHub Desktop.
Force user to Wizard if they haven't completed height, dob, activity level, gender, current weight and target
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
If the user has not completed their BMR fields or target then automatically redirect them to your Wizard page. | |
1) Add this to your theme's functions.php file | |
2) Ensure your Wizard page has the slug "wizard" or modify line 14 to suit. | |
3) Change your redirect URL in line 21 | |
Disclaimer: Use this as at your own risk. It may require modification! | |
*/ | |
function yeken_force_to_wizard() { | |
global $wp; | |
// If we're on the Wizard page or not on a page or not logged in, just exit. Otherwise we'll end up in a loop! | |
if ( false !== strpos($_SERVER['REQUEST_URI'], '/wizard/') || false === is_page() || false === is_user_logged_in() ) { | |
return; | |
} | |
// Redirect | |
if (false === ws_ls_shortcode_if_value_exist(get_current_user_id(), 'is-logged-in,height,weight,dob,target')) { | |
wp_redirect('https://trackyourweight.co.uk/wizard/'); | |
} | |
} | |
add_action('template_redirect', 'yeken_force_to_wizard'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment