How to use filter to disable adding a product to wishlist?

I was almost correct in my attempt.

  • I forgot to add the arguments in my function definition, which is important of course.
  • I took the wrong function name, the _summary at the end was not needed.

The correct code is the following:

/* DISABLE ADD TO WISHLIST FOR USERS WHO AREN'T ADMIN OR SHOP MANAGER */
/* --- */
function remove_add_button ( $allow, $product ) {
    $allow = false;
    $product = $product->get_id();
    return $allow;
    return $product;
}

$user = wp_get_current_user();
if ( ! in_array( 'administrator', (array) $user->roles ) && ! in_array( 'shop_manager', (array) $user->roles ) ) {
    add_filter( 'tinvwl_allow_addtowishlist_single_product','remove_add_button', 15, 2 );
}

As you can see I have also added a condition on the user role, so only admins & shop managers can use the button.