Keep user on specific page based on CB field (similar to Agree to Terms)

1 year 7 months ago #330266 by boyjahq
Is there a way (maybe with an auto action?) to not allow a user to leave a certain page based on a comprofiler field value? We are looking for a behavior similar to how the Agree to Terms part of the CB system plugin works, where if the user clicks on another link they are not allowed to go anywhere until they have agreed to terms in their CB profile.

Please Log in to join the conversation.

1 year 7 months ago #330274 by krileon
It's doable, but it's very tricky and could cause problems for your site depending on what features you're using. From CB Auto Actions you've to use a high up the render chain Joomla event to do that.

Specifically onAfterRoute, which in CB Auto Actions would be joomla_onAfterRoute. You should be sure to condition so that this only applies to frontend and check where they currently are then if they're not where you want them you can redirect using a redirect action type.

That trigger has no variables so you'll have to depend on Code conditions to execute Joomla/CB APIs for more advanced conditioning.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
The following user(s) said Thank You: boyjahq

Please Log in to join the conversation.

1 year 7 months ago - 1 year 7 months ago #330371 by boyjahq
What is the best method to ensure that the auto action only applies to frontend? I tried using [cb:if application_context="frontend"] (ending with [/cb:if]) but it seems that some backend admin actions fall into that category?

I check the relative URL for where the user is with the following php code:
<?php
$currentPageRelUrl = $_SERVER["REQUEST_URI"];
?>

It gives the correct information (I made an auto action that emails me the information as a test) about what page the user has moved to

But for example, if I open the profile for a user in the admin backend, the email auto action with variables revealed tells me that the user has opened /home/index.php

So it seems that some backend actions are being observed as frontend actions?

Please Log in to join the conversation.

1 year 7 months ago - 1 year 7 months ago #330375 by krileon
Use API for everything. You'll need to learn Joomla API to accomplish this properly. Below are some examples.

Checking if frontend from Joomla API:
$isFrontend = JFactory::getApplication()->isClient( 'site' );

Getting GET data from Joomla API
$app = JFactory::getApplication();
$option = $app->input->get( 'option' ); // The component (e.g. com_comprofiler)
$view = $app->input->get( 'view' ); // The component view (e.g. userprofile)

I'm sorry I cannot help you code this as we do not provide coding assistance. Please refer to Joomla API documentation below if you need further API help.

api.joomla.org/


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
The following user(s) said Thank You: boyjahq

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.227 seconds

Facebook Twitter LinkedIn