• I am trying to work on wordpress… but wow, everything is different.

    get_userdata does not exist for me.

    when I do:

    if(function_exists(‘get_userdata’)) {
    echo “get_userdata exists!<br />\n”;
    } else {
    echo “get_userdata does NOT Exist!!!<br />\n”;
    }

    it says the latter… it does NOT exist.

    WP is current.

    Why does it not exist?
    in the codex, it does not say it has been replaced.

    So why cannot I use it now?

    How do I get the role of a user I found their ID with by their email address?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    https://developer.www.ads-software.com/reference/functions/get_userdata/

    Perhaps your files are corrupted or something?

    Thread Starter ukndoit

    (@ukndoit)

    I reinstalled WordPress 5.2.3… by going to updates and clicking re-install…

    still does not work.

    So let me share what I’m doing, maybe that is affecting it.

    I created a mu-plugin.

    TO listen for a webhook that gets posted from another site.

    That webhook wants a 200 ok returned to it, so I did it like this, at the end of when I finish what I need to do with the data in the webhook, I run this function: leaveOkFine();

    the code of which is below:

    function leaveOkFine() {
        eval(header("HTTP/1.1 200 OK"));
        exit;
    }

    I have it eval in case other stuff already ran, so that there are no other headers and it will just print the header 200 ok and exit.

    this is the last thing though, I don’t run it until after I process stuff.

    I have it right now, echo printing data and it does work, I see data process until it hits that, and then it stops right where it is supposed to.

    So how can I tell if wp files are being loaded?
    Is there something I can add in the code that is getting executed to see if wp is loaded?

    I run this code, in part:

    
    if($_REQUEST['somekey'] == "webhookvalue") {
    // webhook is POSTING data... take over...
    
            $_cfirstname = $_REQUEST['customer']['first_name'];
            $_lfirstname = $_REQUEST['customer']['last_name'];
            $_cemail = $_REQUEST['customer']['email'];
            $_cip = $_REQUEST['customer']['ip_address'];
            $_addyline1 = $_REQUEST['customer']['address']['line1'];
            $_addyline2 = $_REQUEST['customer']['address']['line2'];
            $_addycity = $_REQUEST['customer']['address']['city'];
            $_addystate = $_REQUEST['customer']['address']['state'];
            $_addycountry = $_REQUEST['customer']['address']['country'];
            $_addyzip = $_REQUEST['customer']['address']['zip'];
            echo "Visitor First Name is: " . $_cfirstname . "<br />\n";
            echo "Visitor Last Name is: " . $_lfirstname . "<br />\n";
            echo "Visitor EMail is: " . $_cemail . "<br />\n";
            echo "Visitor IP is: " . $_cip . "<br />\n";
            echo "line1 is: " . $_addyline1 . "<br />\n";
            echo "line2 is: " . $_addyline2 . "<br />\n";
            echo "city is: " . $_addycity . "<br />\n";
            echo "state is: " . $_addystate . "<br />\n";
            echo "country is: " . $_addycountry . "<br />\n";
            echo "zip is: " . $_addyzip . "<br />\n";
            echo "Checking for email...<br />";
            $_userloginemail = $_cemail;
            $_muser = get_user_by( 'email', $_userloginemail );
            if($_muser->ID) {
                echo 'User is ' . $_muser->user_login . "( " . $_muser->ID . " )" . " - " . $_muser->first_name . ' ' . $_muser->last_name;
                echo "<br />";
    

    That all works.
    but, did wordpress load the files it uses before this? or does it do it AFTER, and I preempt it by doing the eval and printing the header with 200 ok…?
    Is that way that ‘get_userdata’ function is saying it does not exist?

    If it is preempting it, then is there a way to call it without it printing headers, so I can print the header with 200 ok for the response?

    Thanks,
    -Richard

    Thread Starter ukndoit

    (@ukndoit)

    I think I got it…

    
        foreach ($_muser->roles as $urol) {
             echo "Role is: " . $urol . "<br />\n";
             break;
        }
    

    $urol now has their role… the first role is their level, right?
    if they have custom capabilities roles from like S2member, they would also be listed in their roles, correct? so first one is their actual role?

    Not sure why there would be roleS if only one… so must be there are other ones if they have different roles or something.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘get_userdata still works?’ is closed to new replies.