Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi Doc, this shouldn’t be too tough to pull off.

    The trick is that you need to check to see if the user is logged in. If they aren’t, you serve them the standard “wp_register” and “wp_loginout”.

    A non-logged in user should see this:

    Register | Log in

    If the user is logged in, you check the user info, display the name, and then rather than show the standard admin link with “wp_register”, you make the user’s name a link to the dashboard. And then you follow that up with “wp_loginout” again.

    A logged in user should see this:

    John Doe | Log out

    Check out the code for doing this:

    <?php if (!(current_user_can('level_0'))){ ?>
    
    		<?php wp_register('',' | '); ?><?php wp_loginout(); ?>
    
    <?php } else { ?>
    
    		<a href="<?php echo get_option('home'); ?>/wp-admin/"><?php global $user_login;
    
    		get_currentuserinfo();
    
    		echo $user_login;
    
    		?></a> | <?php wp_loginout(); ?>
    
    <?php }?>

    Here’s more info on the “get_currentuserinfo” function. And here is some info on adding a login form to a theme that I used for the user-based conditional statements.

    <?php wp_register(); ?>
    		<?php wp_loginout(); ?>

    won’t that work?

    Thread Starter drgizmondo

    (@drgizmondo)

    thanks jleuze your code works like a charm.

    @samboll Yeah, that’s usually all I use on my sites, But there have been a couple that had a lot of users where a login form right in the theme would be handy.

    @drgizmondo No problem, happy to help!

    How do you redirect to a page after logging out using wp_loginout();?

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Register/login with user name’ is closed to new replies.