I’m using custom menu for login/logout
here below is my code:
<?php
if(is_user_logged_in()) {
$user = wp_get_current_user();
echo 'Welcome <strong><a href="http://gopalbonline.com/kolkataonwheels/wp-admin/index.php" >'.$user->user_firstname.'</a></strong>
| <a href="<?php echo wp_logout_url( get_permalink() ); ?>" title="Logout">Logout</a>';
} else { ?>
<strong><?php wp_loginout(); ?></strong>
or <a href="<?php bloginfo('url') ?>/wp-login.php?action=register"> <strong>Register</strong></a>
<?php } ?>
but problem is :
- redirect to 404 page not current page…
- I want to add user gavatar if he/she logged in
Any help greatly appreciated.
wp_loginout(get_permalink());
will make hyperlink with “Log out/Log in” text and after log out it will stay in the same page, or it will direct user to log in page.something like this
For example:
Can all be done with WP functions – no custom code required in this case.
You just need to move the code from function.php into the theme and it should work.