From 137a863ce7fc666b726808847dbe3bd5fcb692e2 Mon Sep 17 00:00:00 2001 From: Alex Armstrong Date: Wed, 24 Aug 2016 18:35:53 +0300 Subject: [PATCH] Add getIDByEmail and logoutByEmail --- lib/DiscourseAPI.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/DiscourseAPI.php b/lib/DiscourseAPI.php index 3994106..a02a307 100644 --- a/lib/DiscourseAPI.php +++ b/lib/DiscourseAPI.php @@ -307,5 +307,22 @@ function changeSiteSetting($siteSetting, $value) $params = array($siteSetting => $value); return $this->_putRequest('/admin/site_settings/' . $siteSetting, $params); } + + function getIDByEmail($email) + { + $username = $this->getUsernameByEmail($email); + if ($username) { + return $this->_getRequest('/users/' . $username . '/activity.json')->apiresult->user->id; + } else { + return false; + } + } + + function logoutByEmail($email) + { + $user_id = $this->getIDByEmail($email); + $params = array('username_or_email' => $email); + return $this->_postRequest('/admin/users/' . $user_id . '/log_out', $params); + } }