We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21800
    • 174 Posts
    Hello,
    I use wlpe (amongst others) for a course anouncing system to point directly to the course instructor for info and questions.

    Now, how to replace the mailing of the userlist of wlpe with eform (its because of the custom fields and captcha)?

    In other words: how can eForm get the eMail-adr. of a user shown on a current page for the &to=`?` parameter.
    Any help is appreceated.
      • 21800
      • 174 Posts
      I tried the following:

      a snippet named: eFormEvenFetchMailadr

      <?php
      function fetchEmailadr (&$fields)
      {
      global $modx;
      $fields["email"] = $modx->getPlaceholder("email");
      return true;
      }
      //return empty string
      ?>

      The call:
      [[eFormEvenFetchMailadr]]
      [!eForm? &formid=`ContactForm` &subject=`[+subject+]` &to=`[email protected]` &ccsender=`1` &tpl=`ContactForm` &report=`ContactFormReport` &invalidClass=`invalidValue` &requiredClass=`requiredValue` &cssStyle=`assets/templates/css/Form.css` &gotoid=`46` &vericode=`1` &eFormOnBeforeFormMerge=`fetchEmailadr` !]


      The result:
      The snippet doesn’t return any value (email, username, ...) but text ("hello" instead of $modx->getPlaceholder("email"))

      Where is the mistake? Or is annother way more convenient?
      As result of all, I want the email adr as &to parameter (or as value to an appropriate input field in the form template.
        • 30223
        • 1,010 Posts
        I don’t know much about WPLE but I’m pretty sure that the placeholder view.email is only available within the context of the wlpe snippet. As you are not running wlpe view.email is not available. However if you want to get the email address of the currently logged in user you can change the function to:

        <?php //do not copy this line
        function fetchEmailadr (&$fields)
           {
               if ($_SESSION['webValidated']==1){
                   $fields["email"] =  $_SESSION['webEmail'];
                   return true;
               }elseif($_SESSION['mgrValidated']==1){
                  $fields["email"] =  $_SESSION['mgrEmail'];
                   return true;
               }else{
                   $fields['validationmessage'] = 'Nobody logged in - login before using this form!';
                   return false;
               }
           }
        //return empty string
        


        In your snippet call use &to=`[+email+]`. ( If you have the PHX plugin enabled you may run into trouble. If so check here for a solution )

        Oh and I nearly forgot... eFormOnBeforeFormMerge is probably not the right event to use as this will only be triggered when the form is displayed. Your function would not run when the form is submitted and an email needs to be sent out. Use the eFormOnBeforeMailSent event instead!

        your call would now look like:
        [[eFormEvenFetchMailadr]]
        [!eForm? &formid=`ContactForm` &subject=`[+subject+]` &to=`[+email+]` &tpl=`ContactForm` &report=`ContactFormReport` &invalidClass=`invalidValue` &requiredClass=`requiredValue` &cssStyle=`assets/templates/css/Form.css` &gotoid=`46` &vericode=`1` &eFormOnBeforeMailSent =`fetchEmailadr` !]
        


        &ccsender is superfluous in this case.
          • 21800
          • 174 Posts
          Thanx for your attention TobyL,

          I* ve seen that too and tried "email, username, etc." but without success. There may be a misunderstanding: a user is not logged in when visiting this page.
          On this page only a part of the data of an instructor is shown (there is also a manager page with more data for other purposes) and a possibility shall be given to contact him easily. As wlpe messaging is build for logged users no vericode is implemented (and custom fields are harder to add). So the idea was to combine with eForm.

          So the thing is how to get the email out of the shown (wlpe-) instructor (as the included wlpe messenger does).

          A test snippet I run on the same page also does not succeed either:
          <?php
          $output = '';
          $output .= $modx->getPlaceholder( 'username'); // alt: $wlpe.'username'  
          $output .= $modx->documentIdentifier;
          $output .= '   und etwas Text';
          return $output;
          ?>

          so i feel a bit lost
            • 30223
            • 1,010 Posts
            Ok,... you’ve got me lost too.

            On this page only a part of the data of an instructor is shown
            So where do the instructor details for this page come from?

            So the thing is how to get the email out of the shown (wlpe-) instructor (as the included wlpe messenger does).

            What is wlpe messenger?
              • 21800
              • 174 Posts
              The instructor details for this page come from a wlpe call
              [!WebLoginPE? &type=`users` &usersList=`instructors:default:default:username:ASC:webgroup(instructors:default:default:username:ASC)` !]

              From an event/lesson you can call the appropriate instructor with a link like this
              http://www.sitename.de/instructors.html?service=viewprofile&username=instuctorX

              then the instructor data appears on that page including a mail form (that I called "wlpe messenger") to contact him
              (wlpe template (modified): "wlpeViewProfileTpl" that includes the mail form (which is to be replaced).

              The advantage of all is to give an easy reference to instructors of events/lessons (managed by ditto) by a tv.

                • 30223
                • 1,010 Posts
                Ah, I understand more or less. As I said I’m not so familiar with wlpe yet but I did look through the code a bit. Looks like you’re out of luck here. wlpe parses it’s placeholders internally so they never are exposed to modx->placeHolders. I don’t see a way of fetching that info into eForm at the moment, without some hacks in the wlpe code.
                  • 22827
                  • 129 Posts
                  Old thread I know, did you work it out?

                  I was thinking you might be able to nest a WebLoginPE call inside the eform call, like:

                  [!eform? &to=`[!WebLoginPE? &type=`users` &tpl=`onlyemailaddress`!]`!]
                    • 21800
                    • 174 Posts
                    Thanx very much for your attention, paulkoan
                    it’s not yet worked out, please give me a little time to see, I’m just involved in other things.