WordPress.org

Forums

Mailbag
[resolved] Change redirect... (7 posts)

  1. edtstu
    Member
    Posted 2 years ago #

    How do I add an anchor tage to the redirect URL so it snaps to the same place on the page after the reload?

    Thanks,
    Stu

    https://wordpress.org/plugins/mailbag/

  2. ArrayHQ
    Member
    Plugin Author

    Posted 2 years ago #

    Hi Stu,
    If the form submits successfully, the URL string gets a sent=1 parameter. You can detect this with JS and then scroll to the anchor where your form is.

    Add this to your theme's JS and replace #your-anchor with whatever you have your subscribe form wrapped in.

    
    // Scroll to element on div
    if(window.location.href.indexOf("sent=1") > -1) {
    	$('html, body').animate({
            scrollTop: $("#your-anchor").offset().top
        }, 300);
    }
    
    
  3. edtstu
    Member
    Posted 2 years ago #

    I added:

    <script type="text/javascript">
    // Scroll to element on div
    if(window.location.href.indexOf("sent=1") > -1) {
    	$('html, body').animate({
            scrollTop: $("#beta-signup").offset().top
        }, 300);
    }
       </script>

    to header.php

    doesn't seem to work

    I tried adding just the JS to the main.js but that isn't working either.

    Website: http://getdistilld.com/
    Theme: Agile-WP

  4. John Parris
    Member
    Plugin Contributor

    Posted 2 years ago #

    Hey Stu,

    Try this in your header (changing the two $ to jQuery):

    <script type="text/javascript">
    if(window.location.href.indexOf("sent=1") > -1) {
    	jQuery('html, body').animate({
            scrollTop: jQuery("#beta-signup").offset().top
        }, 300);
    }
    </script>

    I tested this in my browser dev tool and it seems to work ok. Let us know.

  5. edtstu
    Member
    Posted 2 years ago #

    hmm still not working

  6. edtstu
    Member
    Posted 2 years ago #

    I used a different form plugin that doesn't refresh and uses ajax instead. Thanks anyway!

  7. Romeo Crow
    Member
    Posted 1 year ago #

    How/where can I edit the actual code of the plugin to add my own redirect URL, instead of the sent=1 parameter?

    (I don't want it staying on the same page)

    It would be great if a future update of the plugin had "Redirect URL" as an editable field in the plugin options.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.