Feature Requests

Got an idea for a new feature or integration? We’d love to hear it! You can find our roadmap here.

1 vote

Conditional Page Redirects

Use Case:
– I have it set so that my users will be redirected to my Login page if they try accessing their Dashboard page while not logged in.

However, I want to be able to set it so that if they are logged in AND do not have X tag, then redirect them to another page that isn't the Login page.

Declined Category: Core Feature Enhancements Zach Kinsey shared this idea Updated: May 12, 2021

4 thoughts on “Conditional Page Redirects”

  1. Hey Zach,

    For that, you can use this new Default Not Logged In Redirect setting: https://wpfusion.com/documentation/getting-started/general-settings/#default-not-logged-in-redirect

    That should do it, but if not, the wpf_redirect_url filter gives you the option to create whatever kind of logic you’d like: https://wpfusion.com/documentation/filters/wpf_redirect_url/

    At the moment we’re not going to add any kind of conditional redirect rule builder to the access rule settings…. it just makes it too complicated, but if find you regularly need more complicated rules like that, that’s a good case for using WP Fusion alongside a “membership” plugin like MemberPress (https://docs.memberpress.com/article/152-rules-overview), or WooCommerce Memberships (https://docs.woocommerce.com/document/woocommerce-memberships-restrict-content/) which have full rule builders and can support multiple redirect scenarios.

    1. I need this to happen/overide the meta box settings for the page when the conditions below are true:

      REDIRECT:
      – If user is logged in, does NOT have ‘tagName’, AND lands on pageID, then redirect to URL.

      I have this:

      function wpf_redirect_users( $redirect, $post_id ) {

      if ( wpf_is_user_logged_in() ) {
      return $redirect;
      }

      if ( ! wpf_has_tag( ‘myTag’ ) && is_page(myPageID) ) {
      return ‘myURL’;
      }
      }

      add_filter( ‘wpf_redirect_url’, ‘wpf_redirect_users’, 10, 2 );

      It doesn’t work… and I’m not a developer!

      Any guidance would be highly appreciated!

      1. Hmm. Not sure. You want it to run if the user *is* logged in?

        Then I’d change

        if ( wpf_is_user_logged_in() ) {

        to

        if ( ! wpf_is_user_logged_in() ) {

        Because at the moment the rule isn’t running at all on logged in users. The ! negates the condition.

        Otherwise it looks right. If you’re still stuck, we’ve had good luck referring folks to https://codeable.io/, and there are freelancers there who are experienced with WP Fusion

  2. I need this to happen/overide the meta box settings for the page when the conditions below are true:

    REDIRECT:
    – If user is logged in, does NOT have ‘tagName’, AND lands on pageID, then redirect to URL.

    I have this:

    function wpf_redirect_users( $redirect, $post_id ) {

    if ( wpf_is_user_logged_in() ) {
    return $redirect;
    }

    if ( ! wpf_has_tag( ‘myTag’ ) && is_page(myPageID) ) {
    return ‘myURL’;
    }
    }

    add_filter( ‘wpf_redirect_url’, ‘wpf_redirect_users’, 10, 2 );

    It doesn’t work… and I’m not a developer!

    Any guidance would be highly appreciated!

Leave a Comment

Your email address will not be published. Required fields are marked *