Sample PHP code that hide some of the fields for not logged in users. You can add it to the Child Theme functions.php file


 


/**
* Hiding field when user is not registered
*/
add_filter( 'myhome_search_form_fields', function ( $attributes ) {
// display all fields if logged in
if ( is_user_logged_in() ) {
return $attributes;
}


// hide fields if not registered
return array_filter( $attributes, function ( $attribute ) {
// fields ids: 1,2,3 will be hidden
return ! in_array( $attribute->get_ID(), array( 1, 2, 3 ) );
} );
} );


 


You can check id of a field when you edit it in the /wp-admin/ >> MyHome Panel >> Edit field and scroll down