Toolset: mostrar el rol de usuario en un bucle de una vista de usuarios

Add the following custom shortcode to your functions.php file:

function get_user_role_func( $atts )
  $a = shortcode_atts( array(
      'userid' => ''
  ), $atts );
  $userdata = get_user_by('ID', $a['userid']);
  $user_roles = $userdata->roles;
  $user_role = array_shift($user_roles);
  return $user_role;
add_shortcode( 'get_user_role', 'get_user_role_func' );

Then in your View, use the shortcode in a conditional like this:

[wpv-conditional if="( '[get_user_role userid='[wpv-user field='ID']']' eq 'editor' )"]
I am Editor
[wpv-conditional if="( '[get_user_role userid='[wpv-user field='ID']']' eq 'administrator' )"]
I am Admin

Register «get_user_role» in Toolset > Settings > Frontend Content > Third party shortcode arguments.

Visto en Toolset

Deja un comentario

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *

Scroll al inicio

We are using cookies on our website

Please confirm, if you accept our tracking cookies. You can also decline the tracking, so you can continue to visit our website without any data sent to third party services.