Is it possible to add more level ID that will be checked at the same time?
for example:
level 0 should show everything
level 1,2,3,4,5,6,7,8,9 not allowed to show certain widgets?
I can’t figure it out with the code because I can only indicate 1 level id at a time.
my code is now
/**
- Hide widgets by widget instance ID for protected members only content.
- Update the $hide_widget_instances_array with the array of widget instance IDs you want to filter.
- Update the pmpro_hasMembershipLevel check for your membership level IDs.
*
- Add this code below to your PMPro Customizations Plugin – https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_widgets_by_membership_level( $instance, $widget, $args ) { // Set an array of widget areas by ID to filter.
$hide_widget_instances_array = array( ‘bp_core_whos_online_widget-3’ ); // Check if this widget instance should be filtered.
if ( in_array($widget->id, $hide_widget_instances_array ) && ! pmpro_hasMembershipLevel( 1, 2, 3, 4, 5, 6, 7, 8, 9 ) ) {
return false;
}
return $instance;
}
add_filter(‘widget_display_callback’,’my_pmpro_widgets_by_membership_level’, 10 , 3 );