• I’ve just hacked together some code to create a dynamic login box in the menu on WP.
    When the user is logged out, it displays the login form complete with “register” and “lost password” links.
    Once the user is logged in, it displays “Welcome, (their name)!” and a menu.
    The menu can contain generic items such as links to profiles/etc, but then the code can be modified to display additional links depending on what access level the user has.
    Some knowledge of PHP is required.
    You can see it working on my blog at https://www.wellardsworld.com/
    The code is at https://www.wellardsworld.com/code/wp-user.phps
    Suggestions, comments and improvements all welcomed!

Viewing 10 replies - 1 through 10 (of 10 total)
  • Very nice. I had hacked index.php from printing out Login/Register every single time regardless of being logged to printing ‘My Account” when logged in.
    But this is a MUCH nicer way of doing it. Thanks.
    Regards

    This is a great idea.
    unfortunately, i get a lot of code spit out into my header, and regardless of where i put the call
    <?php include('wp-user.php'); ? >
    it appears among the gunk, in the head and not in the menu.
    strange.

    Thread Starter wellard1981

    (@wellard1981)

    Hmm, odd.
    What type of error/code do you get? Can you provide a link to a screenshot?

    I get this on top of every admin page:
    // if the user is logged in, welcome them and display a menu
    Welcome site admin! ????????????????
    ????????????????// it's possible to only display menu items for set access levels, for example anyone over level 0 ????????????????// gets the post link ????????????????????????????????????????????????
    Post an article
    ???????????????? ????????????????// generic links to the logged on users profile and a logout link ????????????????
    Edit your profile
    ????????????????
    Logout
    ????????????????

    and once
    <div id="menu">

      <?php include('wp-user.php'); ? >
      is added to the index.php it returns blank.

    I called:
    <?php include('wp-user.php'); ? >
    have i bone headed it again?
    f.

    Thread Starter wellard1981

    (@wellard1981)

    @dss: not sure what’s going on there?! I’ve put it on a couple of installations of WP, including un-modded ones and it worked a treat.
    @xeophin: removed the font tags, it’ll work without! ??

    great … ??

    sweet using this on my site now ?? thanks

    I tried this plugin out and I got the same thing the first time I tried it out.
    Just to let everyone know, the comments (text following //) are OUTSIDE the PHP context. So they are showing up as regular HTML code. You would want to preface all the comments with <?php //comments are here ?> and that will take care of it. Or just delete the comments. ??
    Regards

    Thread Starter wellard1981

    (@wellard1981)

    For ease of use and convenice, all my modifications are now available in my own WordPress package, this includes the new Dynamic Menu, Comments and New user random password generation.
    See https://www.wellardsworld.com/archives/2004/10/01/get-wellards-world/ for details.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Dynamic Login box for WP’ is closed to new replies.