PluginProbe
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor / 4.0.3
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor v4.0.3
4.0.3 4.0.2 4.0.1 4.0.0 3.16.6 3.16.5 3.16.4 3.16.3 3.16.2 3.16.1 3.16.0 3.15.9 3.9.9 3.9.5 3.9.6 3.9.7 3.9.8 1.1.7 1.1.8 1.1.9 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 All 341 releases
profile-builder / admin / advanced-settings / includes / shortcodes / list-roles.php

list-roles.php in User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor 4.0.3, at admin/advanced-settings/includes/shortcodes/list-roles.php

41 lines 852 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 // Exit if accessed directly
3 if ( ! defined( 'ABSPATH' ) ) exit;
4
5 add_shortcode( 'wppb-list-roles', 'wppb_toolbox_list_roles_handler' );
6 function wppb_toolbox_list_roles_handler($atts){
7
8 $args = shortcode_atts(
9 array(
10 'user_id' => array(),
11 ),
12 $atts
13 );
14
15 $content = '';
16
17 if ( ! empty( $args['user_id'] ) )
18 {
19 $users_id = array_map( 'trim', explode( ',', $args['user_id'] ) );
20 $all_users = get_users();
21
22 foreach ( $all_users as $user )
23 {
24 if ( in_array( $user->ID, $users_id ) )
25 {
26 $roles_list = implode( ', ', $user->roles );
27 $content = $content . $roles_list . '<br>';
28 }
29 }
30 }
31 else {
32 $current_user = wp_get_current_user();
33
34 if ( ! empty( $current_user->roles ) ) {
35 $roles_list = implode( ', ', $current_user->roles );
36 $content = $content . $roles_list;
37 }
38
39 }
40 return do_shortcode( $content );
41 }