PluginProbe
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor / 3.9.9
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor v3.9.9
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 3.9.9, at admin/advanced-settings/includes/shortcodes/list-roles.php

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