Created
April 26, 2022 17:38
-
-
Save hivepress/301255c7912349e05d81f6ffd42227eb to your computer and use it in GitHub Desktop.
Hide the listing pages from non-registered users (redirect to login form) #hivepress #listings
This file contains 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 | |
add_action( | |
'template_redirect', | |
function() { | |
if ( ! is_user_logged_in() && in_array( hivepress()->router->get_current_route_name(), [ 'listing_view_page', 'listings_view_page' ] ) ) { | |
wp_safe_redirect( hivepress()->router->get_return_url( 'user_login_page' ) ); | |
exit; | |
} | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment