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
WordPress: Cambiar fecha de formato Unix a formato Local
$friendly_date = date_i18n( get_option('date_format'), $fechaenunix );
Visto en stackexchange
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
Working with the WordPress user meta query
$args = array(
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'occupation',
'value' => 'developer',
'compare' => 'LIKE' // any value that contains developer
),
array(
'key' => 'billing_country',
'value' => 'United States',
'compare' => '='
),
array(
'key' => 'experience',,
'value' => '5',
'compare' => '>='
)
)
);
$user_query = new WP_User_Query( $args );
Visto en https://usersinsights.com/wordpress-user-meta-query/
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
Toolset: Shortcode para visualizar la fecha de modificación de un post
add_shortcode('wpv-post-modified', 'wpv_post_modified_shortcode');
function wpv_post_modified_shortcode($atts) {
if (empty($atts['format'])) {
$atts['format'] = get_option('date_format');
}
return get_the_modified_date($atts['format']);
}
[wpv-post-modified format="d-m-Y"]
https://toolset.com/forums/topic/adding-a-shortcode-for-the-last-modified-date/