Skip to content

Instantly share code, notes, and snippets.

@yekenuk yekenuk/Force to Wizard
Last active Sep 29, 2017

What would you like to do?
Force user to Wizard if they haven't completed height, dob, activity level, gender, current weight and target
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() ) {
// Redirect
if (false === ws_ls_shortcode_if_value_exist(get_current_user_id(), 'is-logged-in,height,weight,dob,target')) {
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
You can’t perform that action at this time.