PluginProbe
User Access Manager / 2.1.3
User Access Manager v2.1.3
2.3.20 2.3.19 2.3.18 2.3.17 2.3.16 2.3.15 2.3.14 2.3.13 trunk 0.6 0.6.1 0.6.2 0.7 0.7 Beta 0.7.0.1 0.8 0.8.0.1 0.8.0.2 0.9 0.9.1 0.9.1.1 0.9.1.2 0.9.1.3 0.9.1.4 1.0 All 136 releases
user-access-manager / src / Controller / Frontend / LoginControllerTrait.php

LoginControllerTrait.php in User Access Manager 2.1.3, at src/Controller/Frontend/LoginControllerTrait.php

128 lines 2.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * LoginControllerTrait.php
4 *
5 * The LoginControllerTrait trait file.
6 *
7 * PHP versions 5
8 *
9 * @author Alexander Schneider <alexanderschneider85@gmail.com>
10 * @copyright 2008-2017 Alexander Schneider
11 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2
12 * @version SVN: $id$
13 * @link http://wordpress.org/extend/plugins/user-access-manager/
14 */
15 namespace UserAccessManager\Controller\Frontend;
16
17 use UserAccessManager\Controller\BaseControllerTrait;
18 use UserAccessManager\Wrapper\Wordpress;
19
20 /**
21 * Trait LoginControllerTrait
22 *
23 * @package UserAccessManager\Controller
24 */
25 trait LoginControllerTrait
26 {
27 use BaseControllerTrait;
28
29 /**
30 * @var Wordpress
31 */
32 protected $wordpress;
33
34 /**
35 * Returns the user login name.
36 *
37 * @return string
38 */
39 public function getUserLogin()
40 {
41 $userLogin = $this->getRequestParameter('log');
42 return $this->wordpress->escHtml(stripslashes($userLogin));
43 }
44
45 /**
46 * Returns true if the user is logged in.
47 *
48 * @return bool
49 */
50 public function isUserLoggedIn()
51 {
52 return $this->wordpress->isUserLoggedIn();
53 }
54
55 /**
56 * Returns the user name of the current user
57 *
58 * @return string
59 */
60 public function getCurrentUserName()
61 {
62 return $this->wordpress->getCurrentUser()->display_name;
63 }
64
65 /**
66 * Returns the login url.
67 *
68 * @return string
69 */
70 public function getLoginUrl()
71 {
72 return $this->wordpress->wpLoginUrl($this->getRequestUrl());
73 }
74
75 /**
76 * Returns the logout url.
77 *
78 * @return string
79 */
80 public function getLogoutUrl()
81 {
82 return $this->wordpress->wpLogoutUrl($this->getRequestUrl());
83 }
84
85
86 /**
87 * Returns the registration url.
88 *
89 * @return string
90 */
91 public function getRegistrationUrl()
92 {
93 return $this->wordpress->wpRegistrationUrl();
94 }
95
96 /**
97 * Returns the lost password url.
98 *
99 * @return string
100 */
101 public function getLostPasswordUrl()
102 {
103 return $this->wordpress->wpLostPasswordUrl($this->getRequestUrl());
104 }
105
106 /**
107 * Checks if we allowed show the login form.
108 *
109 * @return bool
110 */
111 public function showLoginForm()
112 {
113 return $this->wordpress->isSingle() === true || $this->wordpress->isPage() === true;
114 }
115
116 /**
117 * Returns the login redirect url.
118 *
119 * @return mixed
120 */
121 public function getRedirectLoginUrl()
122 {
123 $loginUrl = $this->wordpress->getBlogInfo('wpurl')
124 .'/wp-login.php?redirect_to='.urlencode($_SERVER['REQUEST_URI']);
125 return $this->wordpress->applyFilters('uam_login_url', $loginUrl);
126 }
127 }
128