Forums

show form data based on Joomla group

faitas 29 Jun, 2014
I am showing data entered in a form using the custome element and the follwoing format.

<?php
$form->data['system_type'];
$form->data['email']
?>
system type is {system_type}
send us an email at {email}

two questions:

1-How can i limit some of the items (eg the email) to users that exist in a specific Joomla group and of cource they are logged in?
2- how can I create an email form to pop up and linking it to the email?

thank you
GreyHead 29 Jun, 2014
1 Likes
Hi faitas,

1. The PHP you have there isn't doing anything useful. You'd need to replace it with some PHP that check the group of the current user. I think that Joomla! has a method that will give you a list of the groups they belong to.

2. The simplest way is probably to create a second form for the 'email form' and include the email (or an id that can be linked to the email) in a link in the page that will be opened in a modal window. The link would be something like this:
<a href='index.php?option=com_chronoforms5&chronoform=xxx&email=aaa@bbb.com' >email us here</a>
but with the modal code added.

Bob
faitas 01 Jul, 2014
thanks for the hints. 1st one is done like the following. working on the the second now.


<?php
$form->data['radio_type'];
$form->data['email']
?>
system type is {radio_type}


<?php
   $user =& JFactory::getUser();
   $uid = $user->id;

   jimport( 'joomla.access.access' );
   $groups = JAccess::getGroupsByUser($uid, false);

   if(in_array(13, $groups)) {
      echo 'Send us an email at '.$form->data['email'] ;
   } else {
      echo 'Subscribe now.';
   }
?>

faitas 02 Jul, 2014
1 Likes
it Worked!!!

Full code below for future reference.

thanks you

<?php JHTML::_('behavior.modal'); ?>
<?php
$form->data['radio_type'];
$form->data['email']
?>
system type is {radio_type}


<?php

   $user =& JFactory::getUser();
   $uid = $user->id;

   jimport( 'joomla.access.access' );
   $groups = JAccess::getGroupsByUser($uid, false);

   if(in_array(13, $groups)) {
      echo "Send us an email at <a class='modal' href='index.php?option=com_chronoforms&chronoform=email_form&email=".$form->data['email']."&tmpl=component' >email us here</a>" ;
   } else {
      echo "Subscribe now.";
   }
?>
faitas 02 Jul, 2014
I realised an issue though in the above approach.
I use radio selection box as a field, and when you do so you have in the options "XXXX= YYY YYY " . using the above method you receive the XXXX and not the YYY YYY which is the right format!

is there any way to output the YYY YYY

thanks.
faitas 02 Jul, 2014
thanks, that worked!
faitas 24 Jul, 2014
I have an other issue now. When the messege from the modal window is sent, I get a blank white page and can not figure out how to load the previous page again.

Any idea?

thanks.
faitas 25 Jul, 2014
i have seen this and have properly placed the Show html, but still does not work.

I get the following errors after submitting the form:



Strict Standards: Non-static method JSite::getMenu() should not be called statically in /home4/*******3/public_html/***********/components/com_sobipro/router.php on line 202

Strict Standards: Non-static method JApplication::getMenu() should not be called statically in /home4/*******3/public_html/***********/includes/application.php on line 536

Strict Standards: Non-static method JSite::getMenu() should not be called statically in /home4/*******3/public_html/***********/components/com_sobipro/router.php on line 202

Strict Standards: Non-static method JApplication::getMenu() should not be called statically in /home4/*******3/public_html/***********/includes/application.php on line 536

Strict Standards: Declaration of JParameter::loadSetupFile() should be compatible with JRegistry::loadSetupFile() in /home4/*******3/public_html/***********/libraries/joomla/html/parameter.php on line 512

Strict Standards: Only variables should be assigned by reference in /home4/*******3/public_html/***********/administrator/components/com_chronoforms/form_actions/show_html/cfaction_show_html.php(142) : eval()'d code on line 2




and after that I see the form again!!! All these on a page whiteout any template on the background!
faitas 25 Jul, 2014
Dear Bob, thank you for replying, but the problem here is not the error reporting. is the fact that after submitting the pop up form, i get a white blank page, which is something that I do not want to and do not know how to control it, change it, handle it.
GreyHead 25 Jul, 2014
Hi faitas,

Sorry, you've lost me completely, I don't know what the problem is? Usually a blank white page is caused by a PHP Error that needs to be fixed.

Bob
faitas 02 Sep, 2014
Hi.
it should not be any conflict related to PHP. I double, tripple checked that.

even in a new joomla installation without anything else installed appart from chronoforms after sending the messege I get redirected to the site

http://<website>/index.php?option=com_chronoforms&email=email@gmail.com&tmpl=component&chronoform=email_form&event=submit

which is a blank page.
GreyHead 02 Sep, 2014
Hi faitas,

I still have no idea what your form is doing - or how you have it set up :-(

If you are using that URL somewhere then it needs to be option=com_chronoforms5 with the 5 at the end if you are using ChronoForms v5.

Bob
faitas 11 Sep, 2014
the solution here turned out to be so easy at the end... 😲

just use the RedirectUser instead of the RedirectURL , or both of them, hut having the Redirect User as the last action!
GreyHead 12 Sep, 2014
Hi Faitas,

Yes, the ReDirect User action has to be the last action because when it runs it redirects the user somewhere else away from ChronoForms.

Bob
This topic is locked and no more replies can be posted.