Forums

Email Verification link path (dynamic)

gemlog 28 Mar, 2012
Since my form gets copied over and over by users I need the path to be dynamic. I was thinking of using $_SERVER['SERVER_NAME'] and $_SERVER['REQUEST_URI'] etc. to get me there, but how to get it into that field in the plugin?

All I can think of so far is to hack the plugin and add (something like/pseudo):
if ( !$link_path ) {
    $link_path = http $_SERVER['SERVER_NAME'] etc.;
}

like the other defaults are done (no, that's not the right $name or syntax, just talking here).

Is there a better way to do this? I don't mind doing it that way, I'd just like to do it within the framework if possible instead for future proofing.

edit: While I'm at it :-)
Prolly last question re v4 (almost promise...)
I get this link in mails attempting to do that manually:
http://blah/index.php?option=com_chronoforms&chronoform=test_11&event=email_verify&action=verify&hash=5392c2111ebc625a02e4837f7da6b590
which fails. I do see the hash stored in the db.

These are my actions:

DB Save
Email Verification Sender
Email [GH] : Send to gemlog
Show Thanks Message



Is the DB save redundant? Also, just what gets added there. I seem to have an extra space.

I'm loving the new flexibility, just not quite catching on to your whole idea I think.
GreyHead 28 Mar, 2012
Hi gemlog,

First off, this seems to be a question about the Email verification action (nothing to do with Email [GH] so I changed the subject once I worked that out).

As far as I can see the Email Verification link is dynamic. Where are you finding that it isn't?

Have you added an email_verify event to your form? You need to add that with the Add Event link and then drag an Email Verification Response action into it and configure it there.

The DB Save action saves your form data into a database table, you need to have this working to be able to save the verification code. There needs to be a table linked to it that includes (at least) the verification code and verification status columns.

Bob
gemlog 28 Mar, 2012
You're right, I got muddled there copying and pasting and then went off and read the wrong action php to boot :-(

Yes a table is connected ok and has those fields. Everything on the form saves fine including the verification code.

It's the 'Email Verification Sender' action that contains the url for 'Email Verification Response' (not email[GH] one down from it). I need 'Verification link path' to always contain the url based on the name of the form it is in rather than be hard coded.

Have you added an email_verify event to your form? You need to add that with the Add Event link and then drag an Email Verification Sender action into it and configure it there.



No, I have an 'On email_verify' event with an 'Email Verification Response' in it. The 'Email Verification Sender' is in the 'On Submit' as I guessed that's where it should go in the sequence. I have these actions in 'On Submit':

DB Save
Email Verification Sender
Email [GH] : Send to gemlog
Show Thanks Message

If I create another event and put the 'Email Verification Sender' action into it, what will trigger it? I'm really not doing very well mapping what I had going in the old version onto the new version am I? :-( Sorry bob.
GreyHead 28 Mar, 2012
Hi gemlog,

Sorry, You are right, it's the Email Verification Response that goes in the new event (I corrected my earlier post).

It's the Verification URL in the email that will trigger this when it's clicked.

I don't understand why you need verification URLs that link to the form??? Save the form name in the table along with the verification link and look it up again when the link is clicked.

Bob
gemlog 28 Mar, 2012

Sorry, You are right, it's the Email Verification Response that goes in the new event (I corrected my earlier post).


Whew! I feel much better now. I was really floundering there.

So is my 'On Submit' ok then? The actions are in the correct order?

It's the 'Email Verification Sender' action that contains the url for 'Email Verification Response' (not email[GH] one down from it). I need 'Verification link path' to always contain the url based on the name of the form it is in rather than be hard coded.


I don't understand why you need verification URLs that link to the form???



http://gemlog.ca/test/verification.png is a small pic of the dialog I'm referring to. The url at the bottom -- mustn't I add the whole url including the form name and event trigger?

When they just copy the form and rename it (they made dozens with the old version), that url will point to the wrong form no?
GreyHead 28 Mar, 2012
Hi gemlog,

Looking at the code, I think that if you leave that box empty then ChronoForms will create a URL to the current form.

Bob
gemlog 28 Mar, 2012
OK, I'll give it a spin. Curious how it will know what I named my event.

http://eg.ca/arpaj25/index.php?option=com_chronoforms&chronoform=test_11&action=verify&hash=a089detc

is what results. This just pulls up the first page of the form, doesn't update my verified field and doesn't trigger anything that I can tell.

edit: I went back to my old string and added &format=raw to it and then it triggered the event. It's great that I have all my {vars} everywhere!

I must be quite close now (except for the dynamic url part).
GreyHead 29 Mar, 2012
Hi gemlog ,

Yes, I see what you mean . . . I think that has to be a bug. Here's a rather crude hack that would get you past this for the moment. Look for this code in the email_verification_sender.php file
		$form->data['verification_link'] = $params->get( 'verification_link_path', $uri->root().'index.php?option=com_chronoforms&chronoform='.$form->form_name );
		$form->data['verification_link'] .= '&action=verify&hash='.$form->data[trim( $params->get( 'verify_field', 'verify' ) )];

And add a couple of extra lines here:
$form->data['verification_link'] = $params->get( 'verification_link_path', $uri->root().'index.php?option=com_chronoforms&chronoform='.$form->form_name );
// add from here . . .
if ( substr($form->data['verification_link'], 0, 7) == '##event:' ) {
  str_replace('##', '', $form->data['verification_link']); 
  $event = explode(':', $form->data['verification_link']);
  if ( isset($event[1]) && $event[1] ) {
     $form->data['verification_link'] = $uri->root().'index.php?option=com_chronoforms&chronoform='.$form->form_name.'&event='.$event[1];
  }
}
// . . .to here
$form->data['verification_link'] .= '&action=verify&hash='.$form->data[trim( $params->get( 'verify_field', 'verify' ) )];
Note: not tested and may need debugging!

You should then be able to put ##event:event_name## (and nothing else) in the Verification link path and have the correct event added to the link.

Bob
gemlog 29 Mar, 2012
Thanks Bob -- I didn't expect you to write anything for me. I don't know that it's a bug, perhaps he meant it that way.

I suppose the right thing to do is to create a personal copy of that plugin with my changes to future proof it against upgrades or changes.

I don't think that code satisfies the 'many or none' doctrine, but I'm sure that would be a very corner case. Certainly I won't have more than one! :-)

edit:
Note: not tested and may need debugging!

Just thought I should make a follow up note in case someone reads this thread and follows along.
As bob said that code won't work, but it's in the right place and anything you do to build the uri to your liking is fine in that place as long as $form->data['verification_link'] gets set correctly somehow.
gemlog 16 May, 2012
Was the file 'email_verification_sender.php' changed in RC3.3? I didn't see a link to a changelog, so I'm just wondering, since I hacked my live copy and don't want things to blow up. chrono 3.2 is working awesomely for me. No one has even hinted at complaining about anything at all since it went live.

If it was changed, what should I be entering now to use it as intended?
GreyHead 16 May, 2012
Hi gemlog,

I did a file compare and the only change seems to be to the Wizard action group the action is shown in.

Bob
gemlog 16 May, 2012
Thanks bob! I'll just plop the hacked file back on top then.
I'll be remembering you and max again soon when the cheque arrives ;-)
This topic is locked and no more replies can be posted.