How to Disable REST API Access for Gue...
Learn how to disable the REST API in your WordPress site for logged-out users and bui...

WPCodeBox
504

Empower site administrators to automatically check “Virtual” and “Downloadable” product options in WooCommerce based on user roles, streamlining product setup.
add_filter( 'product_type_options', 'autocheck_virtual_downloadable');
function autocheck_virtual_downloadable( $args ){
//Set Your targeted user role(s) here
$targeted_user_roles = array( 'administrator', 'vendor' );
// Get the current user object
$user = wp_get_current_user();
// Get the roles of current user
$user_roles = $user->roles;
if ( array_intersect( $targeted_user_roles, $user_roles ) ){
// Auto-Check Virtual and Downloadable Checkboxes
$args['virtual'] ['default'] = "yes";
$args['downloadable']['default'] = "yes";
return $args;
}
}

Redirect users after listing submission on your MyListing website.




