Displaying content for custom routes

We have to build a custom route to manage the login and registration of the site. Now we need to access the custom query variable from the custom route and generate the screens for login and registration. Consider the following code for the implementation of login and registration forms:

add_action( 'template_redirect', 'wqraf_front_controller' );function wqraf_front_controller() {  global $wp_query;  $wpquick_action = isset ( $wp_query->query_vars['wpquick_action'] ) ? $wp_query->query_vars['wpquick_action'] : '';  switch ( $wpquick_action ) {    case 'register':      echo "<h1>REgistration Form</h1>";exit;      break;    case 'login':      echo "<h1>Login Form</h1>";exit;      break;  }}

WordPress executes the template_redirect

Get WordPress Development Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.