2 users online. Create an account or sign in to join them.Users

Search

I am trying to auto login members after they have registered using this form

<xsl:if test="/data/events/create-member[@result='success']">

<form method="post" name="auto">
<input name="fields[email]" type="hidden" value="{events/create-member/post-values/email}" />
<input name="fields[password]" type="hidden" value="{events/create-member/post-values/password/password}" />
<input name="redirect" type="hidden" value="/member-home/" />
<input class="button" name="member-action[login]" type="submit" value="Login now" />
</form>

&lt;script type="text/javascript">
setTimeout('document.auto.submit()',5000);
&lt;/script>

</xsl:if>

It appears that sending the form using Javascript has a different effect to clicking the button. If I click the button I am logged in, if I wait for the Javascript of kick in, I am merely sent to the same page and the event isn't triggered.

Can anyone suggest how I can get the Javascript to trigger the login event?

The value of the submit input doesn't get passed when you submit the form via JavaScript, which is needed to trigger the global login event. You could add a hidden input with the same name attribute member-action[login] and set a value there or you could trigger the click event of the submit input in your JavaScript.

Thanks Jonas I replaced the Javascript with the following and it worked:

    $("document").ready(function() {
        $("#but").trigger('click');
    });

I just wanted to mention that this is more a hack than good practise, triggering a form without user interaction. The auto-login should be handled in an event and somehow communicated. You could create a custom event for that page which gets triggered (via some post values, as normal) when the user sends the registration form. The custom event could then trigger the login-event via setting a value for member-action[login].

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.2 or above
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.0 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details