Conditionally Remove Booking Form on Listing Page

I am looking to remove the booking form if some user meta field isn’t met. Or I would like to disable booking altogether?

I am thinking I would need some filter to remove the booking form, and redirect the checking page if some user meta is not met. Is this possible?

I would handle that with jQuery : it’s not perfect but it’s easily implemented

If meta field exists then
show form
Else
hide it

Hi,

Your request is related to a premium product. Please add the license key to the account settings to access forums for your purchased products and get the Premium Support badge on your profile. If the support for your purchase has expired, please consider renewing it for assistance Renew Support | HivePress

I figured it out:

add_filter(
    'hivepress/v1/templates/listing_view_page',
    function( $template ) {
        $current_user = wp_get_current_user();
        $verified = get_user_meta( $current_user->ID, 'verification', true );
        
        $unverified_content = '<div>ANYTHING </div>';
        
        if ( $verified !== 'verified' ) {
            $template = hivepress()->helper->merge_trees(
                $template,
                [
                    'blocks' => [
                        'page_sidebar' => [
                            'blocks' => [
                                'booking_make_form' => [  // Replace the booking form block
                                    'type'    => 'content',
                                    'content' => $unverified_content,
                                    '_order'  => 15,
                                ],
                            ],
                        ],
                    ],
                ]
            );
        }

        return $template;
    },
    1000
);

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.