Support plugin - re-direct user to Woocommerce login

When someone goes to submit a support ticket, they are taken to the default WP login page. Is there a way so that either visitors (non-members) can submit tickets, or they can be re-directed to the Woocommerce login page instead?

  • James

    Hello Angeljs,
    I couldn't find any hooks within the Support System plugin, so without altering the class-shortcode-submit-ticket-form.php file you would need to add an action in your functions.php file in your theme (hopefully child-theme) folder. Please note that this will redirect all login attempts to your woocommerce login page. You could also use a plugin such as Theme My Login to do that easily as well. TML has options to replace the registration page, login redirects, and several other options too.

    I have not tested the below code with the Support System plugin, but have used it with other plugins that call upon wp_login.php and it works successfully. Let me know if you have any issues with this.

    add_action( 'login_form_login', array( $this, 'redirect_to_woo_login' ) );
    public function redirect_to_woo_login() {
    
              if ( $_SERVER['REQUEST_METHOD'] == 'GET' ) {
    			if ( is_user_logged_in() ) {
    				$this->redirect_logged_in_user();
    				exit;
    			}
    			// If not logged in already go to the woo login page
    			$login_url = home_url( 'replace with woo login page slug' );
    			if ( ! empty( $_REQUEST['redirect_to'] ) ) {
    				$login_url = add_query_arg( 'redirect_to', $_REQUEST['redirect_to'], $login_url );
    			}
    
    			wp_redirect( $login_url );
    			exit;
    		}
    	}

    Thanks,
    James Thomas

  • Ash

    Hi angeljs

    Seems James provided a good fix. He is right, there is no hook for that in support plugin. But you can use the following snippet to change that:

    add_filter( 'login_url', function( $url ) {
    	return 'YOUR CUSTOM LOGIN URL';
    }, 99 );

    Replace "YOUR CUSTOM LOGIN URL" with custom woo login URL. But note that, this will redirect all login url to woo login.

    You can use this code in your theme's functions.php if the theme is not changed. Otherwise mu-plugin is the best option. To create a mu-plugin, go to wp-content/mu-plugins folder. If there is no mu-plugins folder then, create one. Now, inside the mu-plugins folder create file with name anything.php (make sure file extension is .php). Now start with a <?php tag and then put the above code.

    Hope it helps! Please feel free to ask more questions if you have any.

    Have a nice day!

    Cheers,
    Ash

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.