PHP Customization: How to hide property field?
1 minute read
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
Ask the people who build MyHome WPBakery
We answer by email from support@tangiblewp.com. With Premium Support, we also fix your site when something breaks.
We can also run your site for you, or build a new one.
Was this guide helpful?