You may use this code:
<?php
wp_loginout( get_permalink() );
wp_register('', '');
?>
It works even without the plugin.
Thread Starter
danp26
(@danp26)
Thanks webvitaly
Does that mean I cannot use the full fuction of the plugin in header.php ?
The plugin offers slightly more ‘coolness’ than the basic wordpress login function
Thanks again
Danp26
You may take this piece of code of the plugin and put it into your template:
<?php
$redirect_to_self = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
//$redirect_to = $_SERVER['PATH_INFO'];
if( empty( $login_redirect_to ) ){
$login_redirect_to = $redirect_to_self;
}
if( empty( $logout_redirect_to ) ){
$logout_redirect_to = $redirect_to_self;
}
$wrap_before = '<p class="wrap_login_logout">';
$wrap_after = '</p>';
$item_before = '<span class='; // class will be added and the tag is not closed
$item_after = '</span>';
$split_char = ' | ';
echo $wrap_before."\n";
$welcome_text = '[username]';
if ( is_user_logged_in() ){
$current_user = wp_get_current_user();
$username = $current_user->display_name;
$username_link = '<a href="'.admin_url('profile.php').'">'.$username.'</a>';
$welcome_text_new = str_replace('[username]', $username_link, $welcome_text);
echo $item_before.'"item_welcome">'.$welcome_text_new.$item_after.$split_char;
}
echo $item_before;
if ( ! is_user_logged_in() ){
echo '"item_login">';
echo '<a href="'.esc_url( wp_login_url( $login_redirect_to ) ).'">Log in</a>';
}else{
echo '"item_logout">';
echo '<a href="'.esc_url( wp_logout_url( $logout_redirect_to ) ).'">Log out</a>';
}
echo $item_after;
//wp_register();
if ( ! is_user_logged_in() ) {
if ( get_option('users_can_register') ){
echo $split_char.$item_before.'"item_register">'.'<a href="'.site_url('wp-login.php?action=register', 'login').'">Register</a>'.$item_after;
}
}
if ( is_user_logged_in() ) {
echo $split_char.$item_before.'"item_admin">'.'<a href="'.admin_url().'">Site Admin</a>'.$item_after;
}
echo "\n".$wrap_after."\n";
?>
You may modify it as you wish. It is part of the Login-Logout plugin but it can works without the plugin.
Just copy and paste the code where you need it.