Hide field in form based on Wordpress user role

Hi, I am trying to find a way to hide a field in a search form based on user role (Wordpress roles).
This is what I came up with so far:

add_filter (‘bps_before_search_form_filter’, ‘hide_fields’, 10, 1); // note, i made that filter name up…
function hide_fields ($field_ids){
global $current_user;
$user_roles = $current_user->roles;
if (in_array($user_roles, ‘subscribe’){
unset($field_ids[‘id number of field you want to remove’]);
return $field_ids;

Do you need to hide a field in a search form created in UI Builder?

Hello Mark,
sorry this is just a general question. It not related to the UI builder. I watched a YouTube video, made a comment and was referred to this website with my question so I thought I can just ask my question.
I apologize if htis is not the case, I did not mean to violate any website rules.
Unfortunatey, I am not a coder but still am trying to figure out a way to hide a form field for user role (e.g. subscriber).
I highly appreciate any input as to the syntax and how to go about it.

Wishing you a wonderful Friday,

Hi Melanie,

No worries at all. This is a support forum for the Backendless platform, we answer questions and help users who build apps with Backendless.

Unfortunately, we will not be able to assist you with your question as it is not related to Backendless. I recommend posting it to WordPress support or on stackoverflow.com.