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]
[wpv-conditional if="( '[get_user_role userid='[wpv-user field='ID']']' eq 'administrator' )"]
I am Admin
[/wpv-conditional]

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

Visto en Toolset

Mostrar campos de usuario en la columna del administrador

function new_modify_user_table( $column ) {
    $column['test-1'] = 'test 1';
    $column['test-2'] = 'test 2';
    return $column;
}
add_filter( 'manage_users_columns', 'new_modify_user_table' );
 
function new_modify_user_table_row( $val, $column_name, $user_id ) {
    switch ($column_name) {
        case 'test-1' :
            return get_user_meta($user_id, 'wpcf-test-1', true);
        case 'test-2' :
            return get_user_meta($user_id, 'wpcf-test-2', true);
        default:
    }
    return $val;
}
add_filter( 'manage_users_custom_column', 'new_modify_user_table_row', 10, 3 );

Visto en toolset

Bootstrap tooltip

<a href="javascript:void(0);" data-placement="right" data-toggle="tooltip" title="Valeur de la quote-part après expertise">Estimation Q/P</a>
jQuery(document).ready(function () {
  jQuery('[data-toggle="tooltip"]').tooltip();
});

Visto en toolset

Toolset: Mostrar relevancia de los resultados

add_shortcode( 'show_results_relevance', 'show_results_relevance_func');
function show_results_relevance_func($atts) {
    // get the searched terms for main ingredients
    $searched_recipe_main_ingredient = do_shortcode('[wpv-search-term param="wpv-main-ingredient"]');
    if(!empty($searched_recipe_main_ingredient))
    {
        $searched_recipe_main_ingredient_arr = explode(", ", $searched_recipe_main_ingredient);
        // count of searched main ingredients
        $searched_recipe_main_ingredient_count = count($searched_recipe_main_ingredient_arr);
  
        // get attached main ingredients for current post
        $attached_main_ingredients = do_shortcode("[wpv-post-taxonomy type='main-ingredient' format='name' separator=', ']");
  
        if(!empty($attached_main_ingredients))
        {   
            $attached_main_ingredients_arr = explode(", ", $attached_main_ingredients);
             
            // count of common ingredients which were searched and are also attached
            $matched_main_ingredients = count(array_intersect($searched_recipe_main_ingredient_arr,$attached_main_ingredients_arr));        
        }
        else
        {
            $matched_main_ingredients = 0;
        }
  
    }
    else
    {
        $searched_recipe_main_ingredient_count = 0;
        $matched_main_ingredients = 0;
    }
  
 
 
 
    return ($matched_main_ingredients/$searched_recipe_main_ingredient_count*100);
 
}

Visto en Toolset

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.