Support » Plugins » [Function: wp_create_nonce] $user->id insted of $user->ID

  • Resolved Cyberser

    (@cyberser)


    First sorry for my poor english, my native language is spanish.

    Designing a pluggin I found what I think is a bug. In the lines 1178 to 1286 pluggable.php file reads as follows:

    wp_create_nonce function ($ action = -1) {
    $ user = wp_get_current_user ();
    $ uid = (int) $ user-> id;

    $ i = wp_nonce_tick ();

    return substr (wp_hash ($ i. $ action. $ uid, ‘nonce’), -12, 10);
    }
    endif;

    As can be seen on line 1280 says $ user-> id, instead of $ user-> ID;
    This causes PHP throw an error: Undefined property: stdClass:: $ id

    Currently in my pluggin wp_create_nonce I have overwritten the function, but reported to be corrected in the following versions if this is a bug.

    Thanks

Viewing 1 replies (of 1 total)
  • I saw the same thing in other functions. Some research I discovered that “id” (lower case) is not generated automatically in all cases. I’ve solved without having to overwrite functions if after cleaning the cache so as to put ID (uppercase).

    // This throw the error
    wp_cache_delete($_POST[“userid”], ‘users’);
    $current_user = get_userdata($_POST[“userid”]);

    // this work without overwritter
    wp_cache_delete($_POST[“userid”], ‘users’);
    $current_user = get_userdata($_POST[“userid”]);
    $current_user->id = $current_user->ID;

Viewing 1 replies (of 1 total)
  • The topic ‘[Function: wp_create_nonce] $user->id insted of $user->ID’ is closed to new replies.