WordPress.org

Forums

BAW Login/Logout menu
[resolved] BAW Login/Logout Menu and Theme My Login compatibility issue (15 posts)

  1. Daedalon
    Member
    Posted 2 years ago #

    While testing the new 1.3 I noticed something you might want to know. After logging in I was redirected to example.com/login/?action=profile (I'm using Theme My Login). In my user-specific menu now appeared an extra Log out link ("Kirjaudu ulos" in Finnish), except that it's not a clickable link at all.

    It's in a place in the menu between two normal links where there shouldn't be any link at all. The link doesn't have a href attribute. The HTML is <a>Kirjaudu ulos</a>. This element is not displayed on other pages, only on /login/?action=profile where I was redirected after logging in.

    Normally I would be redirected to wp-admin/profile.php which would show otherwise the same page but not inside the theme's normal header, footer, sidebars and navigation menus.

    This is not the Log out link that BAW is supposed to print, that one is correctly printed later in the menu. This does not happen when BAW is turned off.

    Two questions:

    1. Does the same bug happen to you with Theme My Login enabled?
    2. Could a link to that Profile page be added to BAW, the same way as Register?

    An excellent addition to BAW would be the ability to make custom links. The admin would just decide if it's showed to logged-in or logged-out users, the name of the link and the target.

    http://wordpress.org/extend/plugins/baw-login-logout-menu/

  2. Jeff Farthing
    Member
    Posted 2 years ago #

    I don't understand why you need BAW Login/Logout menu with TML.

  3. Daedalon
    Member
    Posted 2 years ago #

    Much like this wordpress.org page says at the top, "Welcome, Daedalon! View your profile (Log Out)", which contains two user-specific links, to profile and to log out. Our intention is to have the same as a proper WP navigation menu.

    BAW Login/Logout Menu is the best solution we've found so far. Although TML is a Swiss knife of a plugin, I didn't notice it yet have a module for creating user-specific menus.

  4. Julio Potier
    Member
    Plugin Author

    Posted 2 years ago #

    ThemeMyLogin
    /includes/class-theme-my-login.php

    line 553:
    if ( is_admin() )
    becomes
    if ( is_admin() or empty( $title ) )

    This is a TML bug ;)

  5. Daedalon
    Member
    Posted 2 years ago #

    Verified, this change fixed the issue. Excellent work once again, Julio. Many thanks!

    Jeff, could you review the change to incorporate it into the next TML update?

  6. Julio Potier
    Member
    Plugin Author

    Posted 2 years ago #

    Sorry Jeff Farthing, i was not aware you were TML owner !
    So i posted it on the plugin's support too, sorry.
    What do you think about that ?

  7. Jeff Farthing
    Member
    Posted 2 years ago #

    I don't understand what that is supposed to do. Also, @Daedalon, you could use TML's Custom User Links module and the widget to do what you want to do.

  8. Daedalon
    Member
    Posted 2 years ago #

    Jeff, I sent you a message via your contact form. If you could reply to it so I'll get your email address, I'll send you a screenshot showing the issue and the result of the fix.

    Thanks about the tip with the module. I had a look at that module earlier, but couldn't fathom whether it supports what I need: links that are shown only depending on whether the user is logged in or out. It seems this is not yet supported by the module. I'm a bit unsure what does the module do overall. It seems that there are two links already that are the same for any user role, but I don't see anything related to them in the Menus or Widgets admin screens. If I remember correctly all the other included modules' purpose and usage were clear to me on the first look, making this the only module that left me looking for additional documentation.

    A sentence or two in the module list and in the module settings screens could help us new users out.

  9. Daedalon
    Member
    Posted 2 years ago #

    Jeff, in case you've replied to my email, it hasn't come through yet.

    Until this fix makes it to the plugin, we're stuck with manually reapplying the patch every time Theme My Login is updated. In the newest plugin version the fix is applied on line 576.

  10. Jeff Farthing
    Member
    Posted 2 years ago #

    That line of code has nothing to do with links...

  11. Daedalon
    Member
    Posted 2 years ago #

    There's another similar submission. I'll continue the discussion there to keep it all together. Hopefully we'll find a solution to the issue on that thread.

    I got your email and sent the screenshot. Thanks for looking into this!

  12. Daedalon
    Member
    Posted 2 years ago #

    I think I figured out the problem, and as it's separate on the other issue, I'll post about it here. This appears to be what happens:

    1. BAWLLM creates a menu item, but returns it as null when logged in:
      case '#bawregister#' : 	if( is_user_logged_in() ) $item = null; else $item->url = site_url( 'wp-login.php?action=register', 'login' ); break;
      		}
      		$item->url = esc_url( $item->url );
      	}
      	return $item;
    2. Right after, TML resumes from BAW's empty string in class-theme-my-login.php, lines 659-665:
      function wp_setup_nav_menu_item( $menu_item ) {
      		if ( 'page' == $menu_item->object && $this->is_login_page( $menu_item->object_id ) ) {
      			$menu_item->title = $this->the_title( $menu_item->title, $menu_item->object_id );
      			$menu_item->url = is_user_logged_in() ? wp_logout_url() : $this->get_login_page_link();
      		}
      		return $menu_item;
      	}
    3. On the login/?action=profile page the_title() sets the menu item with the empty URL and title to have a title (575-582):
      function the_title( $title, $post_id = 0 ) {
      		if ( is_admin() )
      			return $title;
      
      		if ( $this->is_login_page( $post_id ) ) {
      			if ( !in_the_loop() ) {
      				$title = is_user_logged_in() ? __( 'Log Out', 'theme-my-login' ) : __( 'Log In', 'theme-my-login' );
      			} else {

      Because of this, changing the first line inside the_title() to be if ( is_admin() or empty( $title ) ) instead, the symptom disappears. Not sure if it's the perfect solution, though, but it solves this issue and during the time I've now had it on my site, I haven't noticed any errors caused by this.

  13. Jeff Farthing
    Member
    Posted 2 years ago #

    It's not the perfect solution. As I suspected, the bug is on the end of the other plugin.

  14. Daedalon
    Member
    Posted 2 years ago #

    Thanks for the comment, Jeff. What should BAWLLM do instead of returning a null $item?

    Also, do you have an idea why TML sets a title for that $menu_item but not a url?

  15. Daedalon
    Member
    Posted 2 years ago #

    I created a second navigation menu on my theme, and the problem persisted despite having applied the Julio's fix from above.

    Jeff: Does TML support making custom links that can be set to shown only if the user is logged in or out? Are there instructions for this available?

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • BAW Login/Logout menu
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic