Ready to get started?Download WordPress


BAW Login/Logout menu
[resolved] [Plugin: BAW Login Logout Menu] Null object reference at bawllm.php, line 40 (10 posts)

  1. nguyenvuduc
    Posted 2 years ago #

    I found this bug after turned on WP_DEBUG.
    If we add Register menu item into navigation menu, and login, WordPress will throw this bug.

    It is because the statement at line 40 refer to $item object
    $item->url = site_url( 'wp-login.php?action=register', 'login' );
    which has been set to null before.

    Beside, return null from filter of wp_setup_nav_menu_item is illegal.

    Thank you for creating this plugin. It is great.


  2. sampyre
    Posted 1 year ago #

  3. Julio Potier
    Plugin Author

    Posted 1 year ago #

    Thank you both of you, sorry for the delay nguyen.
    I'll try to really fix this asap
    See you !

  4. Ɓukasz Wilk
    Posted 1 year ago #

    Hi there, this plugin is great except this bug mentioned above. Do you have any +/- date when can we expect fix for this bug?

  5. FaithJava
    Posted 1 year ago #

    Hello everyone, as regard the issue above, have fix it in a simple way and I would like to share it with you all.
    1- Add 'Register' Menu on your Header or anywhere you want to put it, you might have error after refreshing, don't worry.

    2- Go to the plugin directory of your 'baw-login-logout-menu' folder and open 'bawllm.php' with any editor of your choice.

    3- Now go to line 38 of the bawllm.php

    4- Change this line of code:
    case '#bawregister#' : if( is_user_logged_in() ) $item = null; else $item->url = site_url( 'wp-login.php?action=register', 'login' );

    4b- Change the above code and replace it with this:
    case '#bawregister#' : if( is_user_logged_in() ) $item->url = site_url(); else $item->url = site_url( 'wp-login.php?action=register', 'login' );

    That will fix it perfectly.


    Kudos to the creator of this plugin.

  6. Julio Potier
    Plugin Author

    Posted 1 year ago #


    I'm on it right now, sorry for the delay.
    Your solution is not correcte, sorry. A entry menu is created but i don't want one because i'm logged in!
    What's your href link result with this !? Is it "correct" and attended ?
    Thanks by the way

  7. Julio Potier
    Plugin Author

    Posted 1 year ago #

    Ok this is now patched, i'll send the update in the next hour.

  8. Julio Potier
    Plugin Author

    Posted 1 year ago #

    1.3.2 is out, this is tested and fixed!

    For you information i did this:

    $item = null;
    $item->title = '#bawregister#';

    and added this:

    add_filter( 'wp_nav_menu_objects', 'bawllm_wp_nav_menu_objects' );
    function bawllm_wp_nav_menu_objects( $sorted_menu_items )
    	foreach( $sorted_menu_items as $k=>$item )
    		if( $item->title==$item->url && $item->title=='#bawregister#' )
    			unset( $sorted_menu_items[$k] );
    	return $sorted_menu_items;

    So i correctly delete the menu entry ;)

  9. FaithJava
    Posted 1 year ago #

    Julio, for me it serve the purpose but anyway will check out your update though.


  10. FaithJava
    Posted 1 year ago #

    Good work Julio, its cool, have check it out nice one.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic


No tags yet.