top of page

Creating a Login Logout Programatically

  • Writer: سُلَيْمَان بْن دَاوُوْد
    سُلَيْمَان بْن دَاوُوْد
  • Jun 27, 2020
  • 1 min read

add_filter( 'wp_nav_menu_items', 'kd_conditional_nav_items', 10, 2 );
function kd_conditional_nav_items( $menu, $args ) {
    if ( 'other-links' == $args->menu ) {
		if ( is_user_logged_in() ) {
			$menu .= '<li class="menu-item logout"><a href="' . wp_logout_url() . '">Logout</a></li>';
		} else {
			$menu .= '<li class="menu-item login"><a href="'.get_field('login_logout_url','option').'">Login</a></li>';
		}
        return $menu;
    }
   
    return $menu;
}
add_action('wp_logout','kd_redirect_after_logout');
function kd_redirect_after_logout(){
     wp_redirect( get_field('login_logout_url','option') );
     exit();
}



 
 
 

Recent Posts

See All
Duplicate Category in Wordpress

The following code helps to duplicate the default wordpress category by help of code. // Add Duplicate option for categories in WordPress...

 
 
 
C#.NET and Its Associated Codes

1- Creating an Desktop Application in C#.NET C# ADO.NET & MySQL MAIN C# and MySQL ADO.NET with Crystals Reports Ready Code 2- Handling...

 
 
 

Comments


© 2020 by syednazrulhassan

bottom of page