Using only blocks I know I can do it since I'm already doing it for other things, but with this mix, basically the conditional display is the issue and I'm not sure how to solve.
I could just do the conditional display in the blocks (sure) but the issue there is that I want the layout to be different, for admins/shop managers I want the current layout which is a list-type product, that's 1 product per line, whereas for non-admins I want 3 products per line in a card-type style.
Thank you for contacting us and I'd be happy to assist.
From the "semi-worked", do you mean that conditional statements are not working as expected or they're working, but you'd prefer an alternative where you don't have to use this combination of blocks and legacy?
You're also welcome to share temporary admin login details so that I can see how these different layouts are set up. I'll be in a better position to suggest some recommendations, accordingly.
Note: Your next reply will be private and making a complete backup copy is recommended before sharing the access details.
To achieve this, you can create one archive, let's call it 'Archive A' that will be shown to everyone, and set it to be assigned to the desired items under the "Loop selection" settings.
Next, you can create another archive, let's call it 'Archive B', that will be shown to only 'administrator' and 'shop_manager' roles, but you'll not assign it to any item under the "Loop selection" settings.
After that, the custom function attached to the "wpv_filter_force_wordpress_archive" filter can check if the current user is either 'administrator' or 'shop_manager' and if the condition is true, change the assigned archive to "Archive B", for that user only:
add_filter( 'wpv_filter_force_wordpress_archive', 'custom_archive_switch_func', 30, 2 );
function custom_archive_switch_func( $wpa_assigned, $wpa_loop ) {
// currently assigned archive
$wpa_to_apply = $wpa_assigned;
// if visitor is logged in
if( is_user_logged_in() ) {
// get current user's role
$user = wp_get_current_user();
$roles = ( array ) $user->roles;
//if user has 'administrator' or 'shop_manager' role
if ( (in_array('administrator', $roles)) || (in_array('shop_manager', $roles)) ) {
// set a different archive
$wpa_to_apply = '12345';
}
}
return $wpa_to_apply;
}
Note: Please replace '12345' with the actual archive ID that you've created for the 'administrator' or 'shop_manager' roles.