Using web services to pass a parameter to a function on elgg remotely

How can I pass a username from another website to elgg and by calling get_user_by_username(username) and user->guid get guid of that user and pass it back to the first website using elgg web services?

  • In the default web services there is no such function. There is plugin which is unfortunately a bit old with a lot of deprecated functions but it still works

    You could use the

    But I have no idea how to pass the email parameter that is required. I modified that function so it returns the username of the logged in user, but I think that is not what you are looking for.

    I think that passing parameters is broken in elgg web_services, but I am not sure.

    I tried adding  ?

    which is usually the method on how to pass parameters.

  • No, it is not broken. Passing additional parameters must be done with &

    So if you add the function below you can get a username with the following url:

     * Web service to get a user registered with an user ID
     * @param string $username to check for
     * @return string $founduser the name of the user
    function user_get_user_by_username($username) {
                    $user = elgg_get_logged_in_user_entity();
            } else {
                    $user = get_user_by_username($username);

            if (!$user) {
                    throw new InvalidParameterException('registration:usernamenotvalid');

            $founduser = $user->username;

            return $founduser;

                                    array('username' => array ('type' => 'string', 'required' => false)
                                    "Get Username by username",

  • But to be honest, this function seems a bit silly.