authentification page in wordpress code example

Example: wordpress set two login pages

<?php
//if you want to show two (different) login pages for two (different) links,
//you can first of all think of two urls for two different login pages.
//here, i have two links =>  /login-old  and  /login-new for which i want different forms,
//now as any of these url hits the browser, i will check for url paramenter 

	$url = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];

	if (strpos($url,'login-new') !== false) {
	    // echo 'to New Login page';
	    $cookie_name = "login_page";
		$cookie_value = "new";
		setcookie($cookie_name, $cookie_value, time() + (86400 * 30), "/"); //will not set immediately, but useful later for logout
    	header("Location: ".site_url('login'));  //this will be your default  login page url
		exit;
      
	} else if(strpos($url,'login-old') !== false) {
    	// echo 'to Old Login page';
	    $cookie_name = "login_page";
		$cookie_value = "old";
		setcookie($cookie_name, $cookie_value, time() + (86400 * 30), "/"); //will not set immediately, but useful later for logout
    	header("Location: ".site_url('login'));  
		exit;
    }

//now that the cookie is set, i know which form to show to user,   
//now, as the user gets redirected to default login page, go to it's template file
//and check for the default login form, where, check,

$login_page = '';
if (isset($_COOKIE['login_page'])) {
	$login_page = $_COOKIE['login_page'];
}

if ($login_page == 'new') {  ?>
  <style>
  #your new form styling here...
  </style>
<?php } else if ($login_page == 'old'){ ?>
  <style>
  #your old form styling here...
  </style>
<?php }

if ($login_page == 'new') { ?>
  <form id="new_form" action="" method="post"> </form>
<?php } else if ($login_page == 'old'){ ?>
  <form id="old_form" action="" method="post"> </form>
<?php } 
//here, check the default login form action attr to put above in our custom forms

Tags:

Php Example