Created
December 15, 2025 04:35
-
-
Save g-maclean/f7d61b64f8af6822df7d9b27eef2273e to your computer and use it in GitHub Desktop.
Property Hive - woocommerce memberships restriction
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
| <?php | |
| /** | |
| * The Template for displaying a single property. | |
| * | |
| * Override this template by copying it to yourtheme/propertyhive/single-property.php | |
| * | |
| * @author PropertyHive | |
| * @package PropertyHive/Templates | |
| * @version 1.0.0 | |
| */ | |
| if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly | |
| ?> | |
| <div class="main-title"> | |
| <div class="title-overlay"> | |
| <div class="container"> | |
| <h1 class="main-title__primary"><?php the_title(); ?></h1> | |
| <h3 class="main-title__secondary">Property Information</h3> | |
| </div> | |
| </div> | |
| </div> | |
| <?php | |
| /** | |
| * propertyhive_before_main_content hook | |
| * | |
| * @hooked propertyhive_output_content_wrapper - 10 (outputs opening divs for the content) | |
| */ | |
| do_action( 'propertyhive_before_main_content' ); | |
| ?> | |
| <?php | |
| $plans = array( 'bronze', 'silver', 'gold' ); | |
| $has_access = false; | |
| if ( function_exists( 'wc_memberships_is_user_active_member' ) ) { | |
| foreach ( $plans as $plan ) { | |
| if ( wc_memberships_is_user_active_member( get_current_user_id(), $plan ) ) { | |
| $has_access = true; | |
| break; | |
| } | |
| } | |
| } | |
| if ( !$has_access ) { | |
| echo '<p>You must be a member to view this property.</p>'; | |
| }else{ | |
| ?> | |
| <a href="/dss-properties/" class="blog-back"><span>←</span>Back to Property List</a> | |
| <?php while ( have_posts() ) : the_post(); ?> | |
| <?php ph_get_template_part( 'content', 'single-property' ); ?> | |
| <?php endwhile; // end of the loop. ?> | |
| <?php | |
| /** | |
| * propertyhive_after_main_content hook | |
| * | |
| * @hooked propertyhive_output_content_wrapper_end - 10 (outputs closing divs for the content) | |
| */ | |
| do_action( 'propertyhive_after_main_content' ); | |
| ?> | |
| <?php } //end of $has_access check ?> | |
| <?php get_footer( 'propertyhive' ); ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment