Screenshot New Years Sale Get the "ALL ACCESS PASS" and Save $349. Unlimited Licenses.
Show All Access Pass

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