function crea_ruolo_ristoratore() { add_role( 'ristoratore', __('Ristoratore'), array( 'read' => true, 'level_0' => true, ) ); } add_action('init', 'crea_ruolo_ristoratore'); function nascondi_prodotti_ristoratori_per_non_ristoratori( $query ) { if ( is_admin() || ! $query->is_main_query() ) { return; } if ( is_shop() || is_product_category() || is_product_tag() ) { if ( ! is_user_logged_in() ) { $tax_query = array( array( 'taxonomy' => 'product_cat', 'field' => 'slug', 'terms' => array( 'ristoratori' ), 'operator' => 'NOT IN', ), ); $query->set( 'tax_query', $tax_query ); } else { $user = wp_get_current_user(); if ( ! in_array( 'ristoratore', (array) $user->roles ) ) { $tax_query = array( array( 'taxonomy' => 'product_cat', 'field' => 'slug', 'terms' => array( 'ristoratori' ), 'operator' => 'NOT IN', ), ); $query->set( 'tax_query', $tax_query ); } } } } add_action( 'pre_get_posts','nascondi_prodotti_ristoratori_per_non_ristoratori' ); function blocca_accesso_shop_ristoratori() { if ( is_page( 'shop-ristoratori' ) ) { // sostituire con lo slug esatto della pagina if ( ! is_user_logged_in() ) { wp_redirect( wp_login_url( get_permalink() ) ); exit; } $user = wp_get_current_user(); if ( ! in_array( 'ristoratore', (array) $user->roles ) ) { wp_redirect( home_url() ); exit; } } } add_action( 'template_redirect', 'blocca_accesso_shop_ristoratori' );

Sample Page

This is an example page. It’s different from a blog post because it will stay in one place and will show up in your site navigation (in most themes). Most people start with an About page that introduces them to potential site visitors. It might say something like this:

Hi there! I’m a bike messenger by day, aspiring actor by night, and this is my website. I live in Los Angeles, have a great dog named Jack, and I like piña coladas. (And gettin’ caught in the rain.)

…or something like this:

The XYZ Doohickey Company was founded in 1971, and has been providing quality doohickeys to the public ever since. Located in Gotham City, XYZ employs over 2,000 people and does all kinds of awesome things for the Gotham community.

As a new WordPress user, you should go to your dashboard to delete this page and create new pages for your content. Have fun!

Assistenza Clienti
Contattaci via Whatsapp