• Resolved pinkish1

    (@pinkish1)


    Hello,

    I installed the plugin and it works great, but it generates this error. I noticed the error when I tried to log into the website as Admin.

    This is the error:

    E_ERROR on line 899 of /home/xxxx/wp-content/plugins/bnfw/bnfw.php.
    
    Uncaught ArgumentCountError: Too few arguments to function BNFW::user_login(),
    1 passed in /home/xxxx/wp-includes/class-wp-hook.php on line 287
    and exactly 2 expected in /home/xxxx/wp-content/plugins/bnfw/bnfw.php:899
    
    Stack trace:
    #0 /home/xxxx/wp-includes/class-wp-hook.php(287): BNFW->user_login('test')
    #1 /home/xxxx/wp-includes/class-wp-hook.php(311): WP_Hook->apply_filters('', Array)
    #2 /home/xxxx/wp-includes/plugin.php(478): WP_Hook->do_action(Array)
    #3 /home/xxxx/wp-content/themes/Framework/functions.php(68): do_action('wp_login', 'test')
    #4 /home/xxxx/wp-includes/class-wp-hook.php(287): nop_auto_login(Object(WP_User), 'test', 'ibgG(KNibHmi$St...')
    #5 /home/xxxx/wp-includes/plugin.php(206): WP_Hook->apply_filters(NULL, Array)
    #6 /home/xxxx/wp-includes/pluggable.php(549): app

    Can you please check what may be wrong?
    My WordPress version is 5.5.1 and PHP version 7.1. Thanks!

    • This topic was modified 4 years, 5 months ago by pinkish1.
Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author bnfw

    (@voltronik)

    Hi @pinkish1,
    Thanks for your message.

    This error seems to be coming from your theme ‘Framework’. Specifically, it’s sending a single argument where the the wp_login action requires two. BNFW is the last function hooking into this action which is why you’re seeing it in the stack trace.
    Your theme needs to pass the relevant details of the user along with a user object where currently it is only passing the user details. Think this was updated in WordPress 4.x.

    Let me know if it helps.

    Thread Starter pinkish1

    (@pinkish1)

    Hello @voltronik and thank you for the very fast reply.

    Thanks for detailing the problem, I will try to fix it.

    Cheers,
    Alex

    • This reply was modified 4 years, 5 months ago by pinkish1.
    Thread Starter pinkish1

    (@pinkish1)

    There is a piece of code in functions.php that allows users to only log in with their usernames, without password. Here is the function:

    add_filter( 'authenticate', 'nop_auto_login', 3, 10 );
    
    function nop_auto_login( $user, $username, $password ) {
        if ( ! $user ) {
            $user = get_user_by( 'email', $username );
        }
        if ( ! $user ) {
            $user = get_user_by( 'login', $username );
        }
    
        if ( $user ) {
            wp_set_current_user( $user->ID, $user->data->user_login );
            wp_set_auth_cookie( $user->ID );
            do_action( 'wp_login', $user->data->user_login );
    
            wp_safe_redirect( admin_url() );
            exit;
        }
    }

    Does this conflict with your plugin? Thanks @voltronik!

    • This reply was modified 4 years, 5 months ago by pinkish1.
    Plugin Author bnfw

    (@voltronik)

    Hi @pinkish1,
    It’s not a conflict so much as the code seems to be outdated. It will cause an issue with any plugin that also uses the wp_login action.
    On the line that says do_action( 'wp_login', $user->data->user_login ); this should be passing two parameters, but it’s only passing one.

    Thread Starter pinkish1

    (@pinkish1)

    I understand, thanks for pointing that out for me.
    I will eliminate that code and will adopt another strategy.
    I will also leave a 5* review for this awesome plugin and support!

    Cheers,
    Alex

    • This reply was modified 4 years, 5 months ago by pinkish1.
    Plugin Author bnfw

    (@voltronik)

    Hi @pinkish1,
    Not a problem! Thanks for your review ??

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘E_ERROR on line 899 of bnfw.php’ is closed to new replies.