We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 25902
    • 27 Posts
    Hi, can anyone help me with an Eform issue? What I have is a contact page using eform with it’s input fields blank, basically visitors gotta fill em up before sending it in.
    However, I would like to have the form’s input fields filled up accordingly if the page is viewed by a registered user.

    For example, I use webloginpe for user admin. So, let’s say that after registering and signing in, a registered user wants to contact me and use the contact form, his name and email fields are already filled up based on user account.


    I’m using MODx Evolution 1.0.0-RC3, with Eform 1.4.4.6 and WebloginPe 1.3.1

    Thanks.
      • 30223
      • 1,010 Posts
      Using the eFormOnBeforeFormParse event, something like this should do it:

      In your form template add placeholders for the values of the name and email fields:template
      <label>Name:</label><input name="name" type="text" eform="Your name::1:" value="[+full_name+]" />
      <label>Email:</label><input name="email" type="text" eform="Email:email:1:"  value="[+user_email+]" />


      Create a new snippet (let’s say you call it ’efWebUserFunction’) and add this function :
      //<?php
      if( !function_exists('efOnBeforeParseFunction') ){
         function efOnBeforeParseFunction(&$fields,&$templates){
            if($_SESSION['webValidated'] ){ //web user logged in?
               $templates['tpl'] = str_replace('[+full_name+]',$_SESSION['webFullname'],$templates['tpl']);
               $templates['tpl'] = str_replace('[+user_email+]',$_SESSION['webEmail'],$templates['tpl']);
            }
            return true;
         }
      }


      Now in your document add this snippet before your eform call and add the event parameter...
      [[efWebUserFunction]]
      [!eForm? &eFormOnBeforeFormParse=`efOnBeforeParseFunction` ...all your other params...!]


      That should do it...

        • 20413
        • 2,877 Posts
        Neat!! smiley
          @hawproductions | http://mrhaw.com/

          Infograph: MODX Advanced Install in 7 steps:
          http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

          Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
          http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
          • 25902
          • 27 Posts
          wow... it works like a charm. Thank you so much! smiley