• I download a plugin (Login to view all) ,and want to modify it furthermore.
    What I want to do is find out who is on the site and he is Not a Customer.
    ( I also download an e-commercial plugin,which would make a new roll called “customer” )

    So I edit the plugin(Login to view all) .
    The plugin only have one php file.
    So I add the code

    wp_get_current_user();
    $iden = $current_user->ID;
    global $wpdb;
    $str = $wpdb->get_var($wpdb->prepare("SELECT meta_value FROM $wpdb->wp_usermeta WHERE meta_key = 'wp_capabilities' and user_id = $iden ;"));
    $rollplayer = unserialize($str); //To see what the roll is.

    and in the if statement , I add $rollplayer!==customer to ask a more specific situation.
    But some problem happened.
    I got
    Fatal error: Call to undefined function wp_get_current_user() in C:\xampp\htdocs\wordpress\wp-content\plugins\login-to-view-all\login-to-view-all.php on line 14
    So, I comment out the wp_get_current_user();
    And there is no error .
    But it seems I can’t get the $iden .
    Of course ,I can’t get the $rollplayer.

    How to make the code work?
    Should I add something more?

    Thanks in advance.

Viewing 1 replies (of 1 total)
  • Thread Starter pheadxp

    (@pheadxp)

    I found a mistake.
    $rollplayer should be an array.
    So the if statement should be !array_key_exists('customer', $rollplayer)

    and also the $wpdb->wp_usermeta Not working.

    Any advice?

Viewing 1 replies (of 1 total)

The topic ‘how to make "wp_get_current_user();" work?’ is closed to new replies.