Last active
March 27, 2026 09:21
-
-
Save propertyhive/145bda0e7502ecf9b0288c7c248864d2 to your computer and use it in GitHub Desktop.
Hide make enquiry for unavailable properties
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| add_action('wp', 'hide_enquiry_for_unavailable'); | |
| function hide_enquiry_for_unavailable() | |
| { | |
| if (!is_singular('property')) | |
| { | |
| return; | |
| } | |
| global $post; | |
| $property = new PH_Property($post->ID); | |
| if ( $property->availability != 'For Sale' && $property->availability != 'To Let' ) | |
| { | |
| remove_action( 'propertyhive_property_actions_list_start', 'propertyhive_make_enquiry_button', 10 ); | |
| add_action( 'propertyhive_property_actions_list_start', 'add_join_mailing_list_action', 10 ); | |
| } | |
| } | |
| function add_join_mailing_list_action() | |
| { | |
| global $property; | |
| ?> | |
| <li><a data-fancybox data-src="#makeEnquiry<?php echo (int)$property->id; ?>" href="javascript:;"><?php echo esc_html(__( 'Join Mailing List', 'propertyhive' )); ?></a></li> | |
| <!-- LIGHTBOX FORM --> | |
| <div id="makeEnquiry<?php echo (int)$property->id; ?>" style="display:none;"> | |
| <h2><?php echo esc_html(__( 'Join Mailing List', 'propertyhive' )); ?></h2> | |
| <p><?php echo esc_html(__( 'This property is no longer available. Join our mailing list below to keep up to date with similar properties that become available.', 'propertyhive' )); ?></p> | |
| <?php echo do_shortcode('[your_shortcode_here]'); ?> | |
| </div> | |
| <!-- END LIGHTBOX FORM --> | |
| <?php | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment