Forums

User information

brononius 05 Feb, 2013
Hey,

I'm trying to make a standard contact form for my website.
In this, i would like to have following data:
[list]
  • Username

  • e-mail

  • message
  • [/list]


    Is there a way to pull the first 2 field from the joomla user tables? This way, the visitor doesn't need to put it in (maybe only change it on the contact form if he wants).
    brononius 05 Feb, 2013
    Hey,

    Thanks for the quick response!

    Seems it's that what I need.
    I just can't figure out how to create a text field with a standard value the joomla username. And when it's not a user or not logged in, it should stay empty. And this field should be viewable since a non user should also be able to fill in the field.

    But i'll give it another try tomorrow. Today i've seen to much computers... :wink:


    Already thanks!!!
    Max_admin 07 Feb, 2013
    Hello,

    If you place the code in a "Custom code" action before the "show html" and the form field name match the index in the data array then this should do it, e.g:
    
    <?php
    $user =& JFactory::getUser();
    $form->data['user_email'] = $user->email;
    ?>
    


    And set your field name to "user_email"

    Regards,
    Max
    Max, ChronoForms developer
    ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
    ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
    brononius 07 Feb, 2013
    hmmm,

    Not working (yet)...
    I don't understand what you mean 'before show html'.

    This is the way i've created the form (wizard edit):

    1. Custom code
    <?php
    $user =& JFactory::getUser();
    $form->data['user_email'] = $user->email;
    $form->data['user_username'] = $user->username;
    ?>


    2. Text Box 1
    Field name: user_username


    3. Text Box 2
    Field name: user_email


    4. Text Area 1

    5. Submit button
    Field name: message



    And this is how my e-mail template looks like

    Username: {user_lidnummer}
    Email: {user_email}
    Message: {message}



    The mail is arriving properly. But the fiels username and email stay empty.
    Nor do i see on the form page the fields being field in...

    Am i missing something?


    Thanks!
    Max_admin 08 Feb, 2013
    The "Custom code" action should be placed BEFORE the "Show html" action inside the "on load" event in your "form wizard".

    Did you try that ?
    Max, ChronoForms developer
    ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
    ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
    brononius 08 Feb, 2013
    Ahhh, big difference between 'Form Wizard' and 'Easy From Wizard'. 😶
    I've created a new form to test it.

    But when i add the code in 'events' - 'On Load', i've got following error:
    Strict Standards: Only variables should be assigned by reference in /administrator/components/com_chronoforms/form_actions/custom_code/custom_code.php(19) : eval()'d code on line 2



    ps i'm using "Joomla! 3.0.2" on a small homeserver (test). Not sure if it's important, but anyway...
    brononius 08 Feb, 2013
    Okay, putting the loglevel to 'none' helps for the warning.
    But my mail arrives empty.
    I've added a debug in the loop (after the custom code)

    Events > First 'on load' > Custom code

    <?php
    $user =& JFactory::getUser();
    $form->data['user_email'] = $user->username;
    ?>



    Preview > text box (Testdata)

    field name = user_email



    The output gives me:

    Data Array:

    Array
    (
    [option] => com_chronoforms
    [tmpl] => component
    [chronoform] => test
    [user_email] =>
    )



    Validation Errors:

    Array
    (
    )



    testdata:
    GreyHead 08 Feb, 2013
    HI brononius,

    This will only work if the user is logged in.

    You probably want their $user->email and not the $user->username

    Other than that the code you posted looks OK to me.

    Bob
    brononius 09 Feb, 2013
    Okay, found what I was doing wrong.
    I configured the form by the backend and tested it with the button "test form".
    And since i wasn't logged in on the frontend, i didn't see the data. 🙄

    So your tip was helpfull!

    And the remark about email/username was also correct. Not the problem, but details can do a lot.😉


    I can start to build the forms now.


    Btw payment is on the way...
    This topic is locked and no more replies can be posted.