Find answers, ask questions, and connect with our
community around the world.

Activity Forums Web Design Wondering why this if else statement with the woocommerce membership plan hook, isn’t working.

  • Wondering why this if else statement with the woocommerce membership plan hook, isn’t working.

    updated 3 weeks, 3 days ago 0 Member · 1 Post
  • Maverick

    Member
    October 26, 2019 at 10:47 am

    Wanting to use a redirect function so that depending if the member has an active plan, they should be directed to the member page. If not, then you proceed to the homepage. This code is half working. When I have a non-active member who did not purchase a plan, they are sent to the homepage, however, when a member who has purchase the plan, they’re also being sent to the home page and not the member page. How can I fix this? CODE: add_filter(‘woocommerce_login_redirect’, ‘wc_login_redirect’); function wc_login_redirect( $redirect_to ) { // Get current user ID $user_id = get_current_user_id(); // Check if the user is member of the plan ‘gold’ if ( wc_memberships_is_user_active_member( $user_id, ‘wasb’ ) ) { $redirect_to = ‘https://myhomepage.com/member’; return $redirect_to; } else { $redirect_to = ‘https://myhomepage.com/’; return $redirect_to;; } } – by hq overview lalamanicer – –

Reply to: Maverick
Your information:

Cancel
Original Post
0 of 0 posts June 2018
Now