1. Home
  2. Docs
  3. UniWP 1.5
  4. User class
  5. Login

Login

WHAT ISCheck if a user account exists. Because this method works inside a Unity project, it doesn’t perform a real login, as it would happen inside a WordPress site.
DONEReturn the ID of the found user. This ID can be used for performing user-related operations on WordPress (for example, get the list of the user’s posts or uploaded media).
ERRORReturn the WordPress system error message (see the WP Code Reference).
USED WP
METHODS
wp_signon

_ = wpUser.$Login$(%user_login%, %user_pass%).$Done$(%doneCallback%).$Error$(%errorCallback%).$Run$();

user_login|string
The user’s username or email address.
__
user_pass|string
The user’s password.
__
doneCallback|function
The function to call when the operation will be completed.
Note: the use of the Done() method is mandatory.
__
errorCallback|(function)
The function to call in case of error.
Note: the use of the Error() method is optional and can be omitted.

{{{#912c9a|WPReply|Data-type|Property or method description}}}
__
.data|string
The ID of the WordPress user.
__
.isOK|bool
true if everything is ok, false in case of error.
__
.isError|bool
true in case of error, false if everything is ok.
__
.error|string
The error message from the Server. It can be a string generated by WordPress through its get_error_message method (see the WP manual).
__
errorType|HttpRequest.Error Enum
The kind of error:
NONE = no error.
HTTP_ERROR = communication error.
SYSTEM_ERROR = UniWP error.
WORDPRESS_ERROR = error message from WordPress REST APIs.

var myUser = new UniWP.User();

_ = myUser.Login("pippo", "pluto123")
    .Done((WPReply reply) => 
    {
        if (reply.isOk) Debug.Log("Loggedin user ID: " + reply.data);
    })
    .Run()
var myUser = new UniWP.User();

_ = myUser.Login("pippo", "pluto123")
    .Done((WPReply reply) => 
    {
        if (reply.isOk) Debug.Log("Loggedin user ID: " + reply.data);
    })
    .Error((WPReply reply) => 
    {
        Debug.LogError(reply.error);
    })
    .Run()