WordPress.org

Ready to get started?Download WordPress

Forums

Subscribe2
[resolved] Suggest:Auto insert email in input text if ispassed by GET (url) or POST(widget (3 posts)

  1. orion42
    Member
    Posted 1 year ago #

    I edited the script to auto-insert the email into the input text box.
    - Check if email is passed by url => if ( isset($_GET['email']))
    - Check if email is passed by form (e.g. from widget) => if ( isset($_POST['email']))

    In this way we can insert a mail into the widget and if we wrote wrong we can see the mistake.
    Or we can pass the email variable by url. E.g. using a link directed to a page with S2 Form, or linking from some page outside in wordpress

    I edited in class-s2-frontend.php, row40 :

    // build default form

    if ( isset($_GET['email'])){ // 42 - If email is passed by url, insert it into input form
    $email_into_form = $_GET['email'];

    $this->form = "<form method=\"post\" action=\"" . $url . "\"><input type=\"hidden\" name=\"ip\" value=\"" . $_SERVER['REMOTE_ADDR'] . "\" /><p><label for=\"s2email\">" . __('Your email:', 'subscribe2') . "</label>
    <input type=\"text\" name=\"email\" id=\"s2email\" value=\"". $email_into_form ."\" size=\"" . $size . "\" /></p><p>" . $this->input_form_action . "</p></form>";

    }elseif ( isset($_POST['email'])){ // 42 - If email is passed by post (e.g. from widget), insert it into input form
    $email_into_form = $_POST['email'];

    $this->form = "<form method=\"post\" action=\"" . $url . "\"><input type=\"hidden\" name=\"ip\" value=\"" . $_SERVER['REMOTE_ADDR'] . "\" /><p><label for=\"s2email\">" . __('Your email:', 'subscribe2') . "</label>
    <input type=\"text\" name=\"email\" id=\"s2email\" value=\"". $email_into_form ."\" size=\"" . $size . "\" /></p><p>" . $this->input_form_action . "</p></form>";

    }else{ // 42 - If email in not passed neither by GET or POST is passed then use standard mode
    if ( $nojs == 'true' ) {
    $this->form = "<form method=\"post\" action=\"" . $url . "\"><input type=\"hidden\" name=\"ip\" value=\"" . $_SERVER['REMOTE_ADDR'] . "\" /><p><label for=\"s2email\">" . __('Your email:', 'subscribe2') . "</label>
    <input type=\"text\" name=\"email\" id=\"s2email\" value=\"\" size=\"" . $size . "\" /></p><p>" . $this->input_form_action . "</p></form>";
    } else {
    $this->form = "<form method=\"post\" action=\"" . $url . "\"><input type=\"hidden\" name=\"ip\" value=\"" . $_SERVER['REMOTE_ADDR'] . "\" /><p><label for=\"s2email\">" . __('Your email:', 'subscribe2') . "</label>
    <input type=\"text\" name=\"email\" id=\"s2email\" value=\"" . __('Enter email address...', 'subscribe2') . "\" size=\"" . $size . "\" onfocus=\"if (this.value == '" . __('Enter email address...', 'subscribe2') . "') {this.value = '';}\" onblur=\"if (this.value == '') {this.value = '" . __('Enter email address...', 'subscribe2') . "';}\" /></p><p>" . $this->input_form_action . "</p></form>\r\n";
    }

    http://wordpress.org/extend/plugins/subscribe2/

  2. mattyrob
    Member
    Plugin Contributor

    Posted 1 year ago #

    @orion42,

    Thanks for that code submission, it might need some sanitisation of the POST and GET variables to make it safer but I'll take a look.

  3. orion42
    Member
    Posted 1 year ago #

    Thanks for inserting in v8.5.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic