martijnH
Admite hilos creados en los últimos 30 días: 0
Debates favoritos del foro
Este usuario no tiene debates favoritos.
Temas del foro creados
Status | Debate | Supporter | Voces | Mensajes | Caducidad |
---|---|---|---|---|---|
View with child post type: hide posts where parent is private/concept
Iniciado por: martijnH
en: Toolset Professional Support
Problem: I have a View of child posts. I would like to apply a query filter so that the View only shows children of parents that are NOT marked "private". Solution: add_filter('wpv_filter_query', 'ts_parent_not_private_func', 10, 3); function ts_parent_not_private_func($query, $view_settings, $view_id) { $views = array( 16813, 16403 ); // only filter these views if( in_array( $view_id, $views ) ) { $child_ids = array(); // we will push IDs here if the parent is not found, or private $children_args = array( 'post_type' => 'training-datum', 'posts_per_page' => '-1', 'post_status' => 'publish', // you may want to add more filters here to improve the performance of this query ); $children = new WP_Query($children_args); foreach( $children->posts as $child ){ $parent = toolset_get_related_post( $child, 'training_training-datum', 'parent' ); // if there is no parent or the parent is private, push this ID into the exclusion array if( !$parent || get_post_status($parent) == 'private' ){ array_push( $child_ids, $child->ID ); } } $query['post__not_in'] = isset( $query['post__not_in'] ) ? $query['post__not_in'] : array(); $query['post__not_in'] = array_merge($query['post__not_in'], $child_ids ); } return $query; } Relevant Documentation: |
2 | 6 | hace 6 años, 3 meses | ||
View with child post type: hide posts where parent is private/concept
Iniciado por: martijnH en: Toolset Professional Support |
4 | 7 | hace 6 años, 3 meses | ||
Toolset commerce: product depending on userrole
Iniciado por: martijnH
en: Toolset Professional Support
Problem: I have a Commerce Form that should add different Products to the User's cart based on their assigned role on the site. One role should receive a free Product, and the other role should receive a paid Product. Solution: In the Form editor, choose the option "Always use the same product regardless of inputs". Select the paid product here to use as the default. Then add this custom code to your child theme's functions.php file: add_filter( 'cred_commerce_add_product_to_cart', 'different_product_by_role', 10, 3 ); function different_product_by_role( $product_id, $form_id, $post_id ) { global $current_user; $user_roles = $current_user->roles; if ( in_array('klant_abonnement', (array) $user_roles) && $form_id == 12345 ) { $product_id = 45678; } return $product_id; } Replace 12345 with the numeric ID of this Commerce Form, and replace 45678 with the numeric ID of the free Product for klant_abonnement Users. Relevant Documentation: |
2 | 3 | hace 6 años, 5 meses | ||
wpv-current-user info="role" not always working (depending on db value)
Iniciado por: martijnH en: Toolset Professional Support |
2 | 2 | hace 6 años, 7 meses | ||
Automate importing content from csv with post relationships
Iniciado por: martijnH en: Toolset Professional Support |
2 | 2 | hace 6 años, 8 meses |