wordpress - Hide a Button with php

I have a button on my wordpress site which should not be visible for some users. I wrote a code in the functions.php but it seems that this does not work. I'm not sure if this is a possible reason:

<?php
function hide_button() {

    $user_id = get_current_user_id();
?>

    <a href="link_that_should_hide" class="page-title-action aria-button-if-js" role="button" aria-expanded="false"

        <?php switch( $user_id ) {
            case X: 
                echo 'style="display:none"';
                break;

        }
        ?>
    
    >Datei hinzuf??gen</a>
<?php
}

add_filter('hide', 'hide_button');

Thanks for your help.

Answer

Solution:

I would use the in_array so you can store the users that are not supposed to see the link easier.

function hide_button()
{
    if (!in_array(get_current_user_id(), [24])) {
        ?>
      <a href="https://xn--werkstattrte-niedersachsen-phc.de/wp-admin/media-new.php"
         class="page-title-action aria-button-if-js" role="button" aria-expanded="false">Datei hinzuf??gen</a>
        <?php
    }
}

add_filter('hide', 'hide_button');

Changes from your original is to not even have the link be available (instead of only hidden from the browser), and to use in_array to allow you to keep adding user_id's as needed.

Source