• edgarfc

    (@edgarfc)


    Two errors:

    First, I can’t save contract address and token Name in NFT Login Plugin settings

    Secord I got this error:

    Plugin Configuration

    Fatal error: Uncaught TypeError: call_user_func(): Argument #1 ($callback) must be a valid callback, class Nft_Login_Admin does not have a method “nft_login_setting_configuration_cb” in C:\xampp\htdocs\test\wp-admin\includes\template.php:1694 Stack trace: #0 C:\xampp\htdocs\test\wp-content\plugins\nft-login\admin\partials\nft-login-admin-display.php(22): do_settings_sections(‘nft-login’) #1 C:\xampp\htdocs\test\wp-content\plugins\nft-login\admin\class-nft-login-admin.php(234): include(‘C:\\xampp\\htdocs…’) #2 C:\xampp\htdocs\test\wp-includes\class-wp-hook.php(307): Nft_Login_Admin->nft_login_init(”) #3 C:\xampp\htdocs\test\wp-includes\class-wp-hook.php(331): WP_Hook->apply_filters(”, Array) #4 C:\xampp\htdocs\test\wp-includes\plugin.php(474): WP_Hook->do_action(Array) #5 C:\xampp\htdocs\test\wp-admin\admin.php(259): do_action(‘toplevel_page_n…’) #6 {main} thrown in C:\xampp\htdocs\test\wp-admin\includes\template.php on line 1694

    Any ideas?

Viewing 15 replies - 1 through 15 (of 23 total)
  • Plugin Author dave123

    (@dave123)

    I am unable to reproduce this error. Can you confirm the plugin version you are installing is the latest 1.1.1? Also, which version of WordPress are you using?

    Thread Starter edgarfc

    (@edgarfc)

    Hi @dave123,

    Thank you for your prompt response.

    I’m using latest plugin version 1.1.1 and latest WordPress version 5.9.1. Should I tried another version?

    I can send screenshots if you want.

    Thank you and looking forward for your comments.

    Edgar

    Thread Starter edgarfc

    (@edgarfc)

    BTW, I’m runnning my wordpress in localhost. Does this makes any difference?

    Plugin Author dave123

    (@dave123)

    I tried a clean WordPress install with no plugins and installed NFT login and no errors. Do you have other plugins installed? Maybe try deactivating them to see if one of them is causing the error. There is now a new 1.2.0 version of the plugin you could try. There isn’t anything specific to address your error but maybe it will work.

    Localhost shouldn’t be a problem. I use localhost for testing too.

    I get the same exact error regarding “nft_login_setting_configuration_cb” on line 1694 of template.php

    I’ve tried every version of your plugin as a test.
    V1.0 does not produce this error but a different error prevents wp-login from loading completely.

    I’d like to use polygon so 1.2.0 will be good for me if we can get this callback to act nice.

    I wonder what configuration works? I have disabled every other plugin and using wordpress 5.9.2 and tried both 2021 and 2022 themes.

    Thread Starter edgarfc

    (@edgarfc)

    Hi @inventionstore, If you find solution of this let me know.

    I’ll highly appreciate it.

    Thanks,

    This isn’t the answer, but so far I removed lines 184-190 from class-nft-login-admin.php

    // Configuration section
          //  add_settings_section(
          //      $this->option_name. '_configuration',
          //      __( 'Plugin Configuration', 'nft-login' ),
        //        array( $this, $this->option_name . '_configuration_cb' ),
        //        $this->plugin_name
      //      );

    There is no more error, but I don’t see any indication that the plugin is functioning.

    I’m getting closer now.
    The NFT_Login_Admin class starting on line 22 of class-nft-login-admin.php does not have a nft_login_setting_configuration_cb callback function defined, so I added to it:

    public function nft_login_setting_configuration_cb( $arg ) {
    		    // echo section intro text here
    		    echo '<p>id: ' . $arg['id'] . '</p>';             // id: eg_setting_section
    		    echo '<p>title: ' . $arg['title'] . '</p>';       // title: Example settings section in reading
    		}

    Now, within the plugin admin settings screen I get the output of ‘id’ and ‘title’ and a checkbox for enabling the nft login appears.(that’s progress)

    But, when going to the login screen I get the following error:

    Warning: Undefined property: WP_Error::$roles in /var/www/html/wp-content/plugins/nft-login/public/class-nft-login-public.php on line 117
    
    Fatal error: Uncaught TypeError: in_array(): Argument #2 ($haystack) must be of type array, null given in /var/www/html/wp-content/plugins/nft-login/public/class-nft-login-public.php:117 Stack trace: #0 /var/www/html/wp-content/plugins/nft-login/public/class-nft-login-public.php(117): in_array() #1 /var/www/html/wp-includes/class-wp-hook.php(307): Nft_Login_Public->authenticate() #2 /var/www/html/wp-includes/plugin.php(189): WP_Hook->apply_filters() #3 /var/www/html/wp-includes/pluggable.php(608): apply_filters() #4 /var/www/html/wp-includes/user.php(95): wp_authenticate() #5 /var/www/html/wp-login.php(1211): wp_signon() #6 {main} thrown in /var/www/html/wp-content/plugins/nft-login/public/class-nft-login-public.php on line 117

    So, I think the callback has to be properly defined for this to work.

    Plugin Author dave123

    (@dave123)

    Yes, thanks for the help. The callback name got changed in a prior version. I think some of us may be running with looser error handling so the missing function didn’t cause a fatal error and the plugin appeared to be working. I added the function back in version 1.2.1 of the plugin. Hopefully this will fix your error

    Ok, sorry for all the updates.
    I commented out $isAdministrator line 115 from class-nft-login-public.php

    public function authenticate( $user, $username, $password) {

    //$isAdministrator = in_array(‘administrator’, $user->roles);

    Now the login page loads and it looks like it might work but you can’t login as administrator.

    I think something about that line needs to updated. I can’t find the link but something about PHP8 doesn’t allow for unsafe return values.

    Anyway, I think this may allow the plugin to function partially.
    Keep in mind I’m trying these things on a completely blank WordPress site that I don’t care about destroying. And, I might be causing security issues. I’m just messing around with the code without really knowing how it works.

    I tried changing the $isAdministrator line to:

    $isAdministrator = array();
    $roles = array('administrator');
    $user = wp_get_current_user();
    foreach ($roles as $role){
      if ( in_array( $role, (array) $user->roles ) ) {
         $isAdministrator = in_array('administrator', $user->roles);
      }
    }

    It doesn’t block the login page but still won’t allow admin to login without verifying NFT ownership. (I actually like this better anyway)

    The question is, how can you check if the user is administrator if they aren’t logged in yet?

    Plugin Author dave123

    (@dave123)

    Give version 1.2.2 a try. Thanks for helping!

    It works perfectly now. Awesome!

    Thread Starter edgarfc

    (@edgarfc)

    Hey @dave123 thanks for the update, looks like I can update and save the plugin, however I’m getting weird messages about “Contract Address not found on Ethereum”…

    Does the contract requires specific function or code to work with your plugin?

    Here is my contract URL:
    https://etherscan.io/address/0x1010e297b3022d53847fa004a4553d66a8292b55

    Token Name: InfinityDragons
    Contract Address: 0x1010e297b3022d53847fa004a4553d66a8292b55

    I tried with two different wallets who I’m 100% they own some tokens (NFT) of that collection.

    @inventionstore any luck on your side?

    I’m waiting for matic to transfer into my wallet so I can mint an nft.
    I added your contract address and put the name Infinity.
    It seems like it should work, it saved the settings with no errors and if I try to log in it says ‘connected address does not own token’ – as expectd.

Viewing 15 replies - 1 through 15 (of 23 total)
  • The topic ‘Error when installing and can’t save contract/token names’ is closed to new replies.