ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Forgot Password Template

November 30, 2008 1:18pm

Subscribe [5]
  • #1 / Nov 30, 2008 1:18pm

    Christian Sweatt's avatar

    Christian Sweatt

    281 posts

    I am trying to incorporate my site design into the ‘Forgotten Password’ template.  I’ve noticed that this is quite a bit more involved than I originally thought.  Will this require me to change ALL member templates as well?  It seems like the for. pass. template automatically pulls in the same header that is used on the other member templates.

    Am I correct in this?

  • #2 / Dec 01, 2008 8:11am

    Peter Lewis's avatar

    Peter Lewis

    280 posts

    This may be a stupid question, but why are you incorporating your template into the forgotten password template, why not the other way around and simply dump the following form in your template:

    <form id='forgot_password_form' method="post" action="http://YOUR URL/index.php"  >
                                <div class='hiddenFields'>
                                    <input type="hidden" name="XID" value="{XID_HASH}" />
                                    <input type="hidden" name="ACT" value="11" />
                                    <input type="hidden" name="RET" value="-3" />
                                    <input type="hidden" name="FROM" value="" />
                                    <input type="hidden" name="site_id" value="1" />
                                </div>
                                <fieldset>
                                    <legend>Please enter your login details:</legend>
                                    <label for="email">Email</label><input id="email" name="email" value="" maxlength="100" type="text" title="Please enter the email address that you registered with." class="required email" /><br >
                                    <button class="submitButn" type="submit" name="submit" value="Submit form">Submit</button>
                                </fieldset>
                            </form>

    I gave up trying to incorporate stuff into the built-in templates, as there were always bits that wouldn’t work (mainly this was in message templates, etc).

  • #3 / Dec 01, 2008 10:24am

    Christian Sweatt's avatar

    Christian Sweatt

    281 posts

    So, you’re saying to just create my own, new template within my site templates and name it something like “forgot_password”, then dump the code example you provided into my template, and not even worry with the member templates?

    If that is what you’re saying, I didn’t even know you could do that.

  • #4 / Dec 01, 2008 10:30am

    Peter Lewis's avatar

    Peter Lewis

    280 posts

    Yep.

    I’ve got a custom login form here: http://www.avabooks.ch/index.php/ava/login which has a link to the forgotten password page.

    Then http://www.avabooks.ch/index.php/ava/resetpassword is the form above.

    Neither of these use the membership templates.

    Peter.

  • #5 / Dec 01, 2008 10:36am

    Christian Sweatt's avatar

    Christian Sweatt

    281 posts

    It does seem a lot simpler to just create your own templates than to work around what EE has provided.  That’s what my original post was all about.

    Thanks for the info!

  • #6 / Jun 24, 2010 5:20am

    LucPestille's avatar

    LucPestille

    146 posts

    @Twobelowzero - how did you deal with the password reset function and not showing the EE CP? I think there were some redirects in there, but it was so quick I didn’t catch it - I didn’t see anything EE branded, which is what I need to do too…

    Thanks,


    Edit - I think I’ve figured it - using the custom forgotten password form uses my user message templates automagically… Now to deal with the missing index.php from the reset link…

  • #7 / Jun 24, 2010 6:20am

    Peter Lewis's avatar

    Peter Lewis

    280 posts

    Hi Luc,

    I usually send the form via Ajax, so it’s seamless.

    I’m using the JQuery validation plugin but you could call the SubmitPasswordReset() function directly on the form submit button…

    Here’s the JavaScript for the validation trigger and Ajax call:

    //###   RESET PASSWORD   ###
        $("#forgot-password-form").validate({
            submitHandler: function(form) {
                //###   Disable the Submit button   ###
                $("#forgot-password-form button").fadeTo("slow", 0.20).attr("disabled","disabled");
    
                SubmitPasswordReset();
                return false;
            }
        });
    
    //###   RESET PASSWORD FORM SUBMISSION   ###
    function SubmitPasswordReset() {
        //###   Send form via AJAX   ###
        $.ajax({
            type: "POST",
            data: $("#forgot-password-form").serialize() + "&action;=" + $("#forgot-password-form").attr("action"),
            dataType: "html",
            success: function (html) {
                //###   Successfully received an html page from the server   ###
                if ( html.search(/error/i) >= 0 ) {
                    if (html.search(/not found/i) >= 0) {
                        $("#pwd-reset-email").addClass('error');
                        $("#pwd-reset-email").after('<label class="error" for="login-username" generated="true">Email address doesn\'t exist
    Re-check or register an account</label>');
    
                    } else if (html.search(/already logged in/i) >= 0) {
                        $("#forgot-password-form button").after('<label class="error" for="login-username" generated="true">User already logged in!</label>');
    
                    } else if (html.search(/account has not been activated yet/i) >= 0) {
                        $("#forgot-password-form button").after('<label class="error" for="login-username" generated="true">Account has not been activated yet
    Check your email and activate</label>');
    
                    } else {
                    }
    
                    $("#forgot-password-form button").fadeTo("slow", 1).removeAttr("disabled");
    
                } else {
                    //###   Successfully sent reset request   ###
                    //"Instructions for resetting your password have just been emailed to you."
                    $("#forgot-password-form").hide();
                    $("#password_reminder .form-success").slideDown("slow");
    
                    //###   Show/hide user nav links   ###
                    ClearForm("#forgot-password-form");
    
                    //###   Close PrettyPhoto Popup Window   ###
                    var currentURL = new Array();
                    currentURL = top.location.href.split('#');
                    top.location.href = currentURL[0] + "#close-pp-delay";
                }
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                //###   Error occurred, could be server, CMS or 404   ###
                //alert(textStatus + errorThrown);
                $("#forgot-password-form button").fadeTo("slow", 1).removeAttr("disabled")
            },
            complete: function (XMLHttpRequest, textStatus) {
                //alert(textStatus);
            }
        });
    } //###   End of SubmitLogin function   ###

    Note the checks in there for the various errors from EE.

    I can’t recall what I did for the AVA site or what the above does without JavaScript - think the EE panel will appear, which I’ve customised to give it some branding.

    Hope this is helpful.

    Peter

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases