Home › Forums › Chit Chat › WPLMS customizations › stop non-logged in user in accessing the cart and check out page?
- This topic has 2 replies, 1 voice, and was last updated 9 years ago by thorne13.
Viewing 3 posts - 1 through 3 (of 3 total)
-
AuthorPosts
-
December 6, 2015 at 7:07 am #12439thorne13SpectatorHi, I would like to ask how can I stop non-logged in user in accessing the cart and check out page? I don't know the equivalent of the code <span style="color: #dd1144; font-family: Monaco, MonacoRegular, 'Courier New', monospace; white-space: pre;">'bp_before_directory_course_page' </span>if i will use it in the cart and checkout page. Should I use <span style="color: #dd1144; font-family: Monaco, MonacoRegular, 'Courier New', monospace; white-space: pre;">'bp_before_cart_page'</span>? I have used the command below in stopping non logged in user to access the course page and it worked <span class="crayon-e" style="box-sizing: border-box; height: inherit; white-space: pre; font-family: Monaco, MonacoRegular, 'Courier New', monospace !important; font-size: inherit !important; line-height: inherit !important; color: teal !important;">add_action</span><span class="crayon-sy" style="box-sizing: border-box; height: inherit; white-space: pre; font-family: Monaco, MonacoRegular, 'Courier New', monospace !important; font-size: inherit !important; line-height: inherit !important;">(</span><span class="crayon-s" style="box-sizing: border-box; height: inherit; white-space: pre; font-family: Monaco, MonacoRegular, 'Courier New', monospace !important; font-size: inherit !important; line-height: inherit !important; color: #dd1144 !important;">'bp_before_directory_course_page'</span><span class="crayon-sy" style="box-sizing: border-box; height: inherit; white-space: pre; font-family: Monaco, MonacoRegular, 'Courier New', monospace !important; font-size: inherit !important; line-height: inherit !important;">,</span><span class="crayon-t" style="box-sizing: border-box; height: inherit; white-space: pre; font-family: Monaco, MonacoRegular, 'Courier New', monospace !important; font-size: inherit !important; line-height: inherit !important; font-weight: bold !important; color: #800080 !important;">array</span><span class="crayon-sy" style="box-sizing: border-box; height: inherit; white-space: pre; font-family: Monaco, MonacoRegular, 'Courier New', monospace !important; font-size: inherit !important; line-height: inherit !important;">(</span><span class="crayon-v" style="box-sizing: border-box; height: inherit; white-space: pre; font-family: Monaco, MonacoRegular, 'Courier New', monospace !important; font-size: inherit !important; line-height: inherit !important; color: #002d7a !important;">$this</span><span class="crayon-sy" style="box-sizing: border-box; height: inherit; white-space: pre; font-family: Monaco, MonacoRegular, 'Courier New', monospace !important; font-size: inherit !important; line-height: inherit !important;">,</span><span class="crayon-s" style="box-sizing: border-box; height: inherit; white-space: pre; font-family: Monaco, MonacoRegular, 'Courier New', monospace !important; font-size: inherit !important; line-height: inherit !important; color: #dd1144 !important;">'redirect_if_not_loggedin'</span><span class="crayon-sy" style="box-sizing: border-box; height: inherit; white-space: pre; font-family: Monaco, MonacoRegular, 'Courier New', monospace !important; font-size: inherit !important; line-height: inherit !important;">)</span><span class="crayon-sy" style="box-sizing: border-box; height: inherit; white-space: pre; font-family: Monaco, MonacoRegular, 'Courier New', monospace !important; font-size: inherit !important; line-height: inherit !important;">)</span><span class="crayon-sy" style="box-sizing: border-box; height: inherit; white-space: pre; font-family: Monaco, MonacoRegular, 'Courier New', monospace !important; font-size: inherit !important; line-height: inherit !important;">;</span> Thanks!December 6, 2015 at 8:35 am #12440thorne13SpectatorHi, I would like to ask how can I stop non-logged in user in accessing the cart and check out page? I don't know the equivalent of the code add_action('bp_before_directory_course_page',array($this,'redirect_if_not_loggedin')); if i will use it in the cart and checkout page. Should I use 'bp_before_cart_page' ? I have used the command below in stopping non logged in user to access the course page and it worked add_action('bp_before_directory_course_page',array($this,'redirect_if_not_loggedin')); function redirect_if_not_loggedin(){ if(!is_user_logged_in()){ $location = get_site_url(); // Change this location to a static url where you want to redirect the user to. echo '<script type="text/javascript"> <!-- window.location= "'. $location .'"; //--> </script>'; exit(); } } Thanks!December 8, 2015 at 10:56 am #12789thorne13SpectatorI have found a way already using the Paid Membership Pro and the tweak given here. Just assigned the page to be accessible by the member only.
-
AuthorPosts
Viewing 3 posts - 1 through 3 (of 3 total)
- The topic ‘stop non-logged in user in accessing the cart and check out page?’ is closed to new replies.