PluginProbe
Restrict User Access – Ultimate Membership & Content Protection / 2.8
Restrict User Access – Ultimate Membership & Content Protection v2.8
trunk 1.3 2.0 2.1.3 2.2.3 2.3.2 2.4 2.4.1 2.4.2 2.4.3 2.5 2.6 2.6.1 2.7 2.7.1 2.8 2.8.1
restrict-user-access / src / Shortcode / UserLevels.php

UserLevels.php in Restrict User Access – Ultimate Membership & Content Protection 2.8, at src/Shortcode/UserLevels.php

39 lines 838 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace RestrictUserAccess\Shortcode;
4
5 /**
6 * Class UserLevels
7 *
8 * @author Joachim Jensen <joachim@dev.institute>
9 * @license https://www.gnu.org/licenses/gpl-3.0.html
10 */
11 class UserLevels implements ShortcodeInterface
12 {
13 public function get_names()
14 {
15 return [
16 'rua-user-levels'
17 ];
18 }
19
20 public function get_callback($atts, $content = null)
21 {
22 $a = shortcode_atts([
23 'id' => null
24 ], $atts, 'rua-user-level');
25
26 $user = rua_get_user($a['id']);
27
28 $levels = \RUA_App::instance()->get_levels();
29 $level_names = [];
30 foreach ($user->get_level_ids() as $id) {
31 if (isset($levels[$id])) {
32 $level_names[] = $levels[$id]->post_title;
33 }
34 }
35
36 return implode(', ', $level_names);
37 }
38 }
39