Skip to content

Commit 137a863

Browse files
committed
Add getIDByEmail and logoutByEmail
1 parent 1acfae4 commit 137a863

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

lib/DiscourseAPI.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,5 +307,22 @@ function changeSiteSetting($siteSetting, $value)
307307
$params = array($siteSetting => $value);
308308
return $this->_putRequest('/admin/site_settings/' . $siteSetting, $params);
309309
}
310+
311+
function getIDByEmail($email)
312+
{
313+
$username = $this->getUsernameByEmail($email);
314+
if ($username) {
315+
return $this->_getRequest('/users/' . $username . '/activity.json')->apiresult->user->id;
316+
} else {
317+
return false;
318+
}
319+
}
320+
321+
function logoutByEmail($email)
322+
{
323+
$user_id = $this->getIDByEmail($email);
324+
$params = array('username_or_email' => $email);
325+
return $this->_postRequest('/admin/users/' . $user_id . '/log_out', $params);
326+
}
310327
}
311328

0 commit comments

Comments
 (0)