Screenshot WOW SAVE 20% on the All Access Bundle. Use "OAUTH20OFF" at checkout.
GET DEAL
3rd Party Integration

Custom Login Page

Published: August 14, 2019 | Updated: December 29th, 2019
  1. Home
  2. Docs
  3. How To
  4. Custom Login Page

Overview

The WP OAuth Server plugin allows for you have a custom login page and still provide OAuth services.

/**
 * CUSTOM LOGIN REDIRECT
 *
 * Redirect a user to a custom login page for authentication
 */
add_action( 'wo_before_authorize_method', 'custom_login_redirect' );
function custom_login_redirect() {
	if ( ! is_user_logged_in() ) {
		wp_redirect( site_url() . '/custom-login?redirect_to=' . urlencode( site_url() . $_SERVER['REQUEST_URI'] ) );
		exit;
	}
}

Applying the Custom Login Code

Extending WP OAuth Server can be done via the current themes functions file. Read more about the functionality of a themes function file by visiting https://developer.wordpress.org/themes/basics/theme-functions/.

Place the snippet from above in your functions.php file. You may need to change the parameter for redirect to work with your custom needs.

Icon