Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author 123host

    (@123host)

    No, that would defeat the purpose of this plugin.

    If a petition is sent to a target e.g. The Mayor, then it would be expected by the recipient that a way to reply in the same manner it is received would be included. That is, if sent by email their would be an email address. If sent by post there would be a street address.

    That is how I think about it…convince me otherwise ;o)

    Thread Starter Sadulla

    (@saadulla1)

    I see 🙂
    But actually I’m about to make a petition to some refugees who may does not have email addresses.
    I have added a phone number choice and also email address and make neither phone or email address required with javascript.

    I also tried to remove required property in emailpetition.php

    if ( $petition->hide_email_field != 1 ) {
    $petition_form .= ‘<div class=”dk-speakout-full”>
    <input name=”dk-speakout-email” id=”dk-speakout-email-‘ . $petition->id . ‘” value=”‘ . $userdata[ ’email’ ] . ‘” type=”email” placeholder=”‘ . __( ‘Email’, ‘speakout’ ) . ‘” required=”required” /></div>’;
    }`

    And remove the following from public.js

    // if email is empty or doesn’t fit regext and IS being displayed
    if ( ( email == ” || emailRegEx.test( email ) == false ) && hide_email_field == 0 ) {
    $( ‘#dk-speakout-email-‘ + id ).addClass( ‘dk-speakout-error’ );
    errors ++;
    }`

    But when I try to submit form with an empty email, I can not add another entry with empty, it says already submitted with the same email address!

    Plugin Author 123host

    (@123host)

    Nice work trying to get around it ;o)

    The issue you are hitting is that it is saving the email field as being empty. Nothing wrong with that the first time.

    However the plugin is designed to stop anyone signing a signature with the same email address more than once. Two blank email addresses are seen as the same when trying to save to the database.

    You seem to have the skills, if it were me, I would write some code to pre-fill the email address with a_random_string@different_random_string.random_3_character_string and in class.mail.php prevent the email address being included.

    I hope that helps.

    Thread Starter Sadulla

    (@saadulla1)

    Yes, exactly!
    Actually I just want to find the if condition code for same email confirmation.

    Can you tell me when I can find and disable it?

    Also I’ll appreciate if you could tell me your way(random_string) to do this process.

    Plugin Author 123host

    (@123host)

    You could make your life a bit easier when there is an upgrade to the plugin as all your changes will be lost. However if you do a simple change in one place, after an upgrade it is easy to add again.

    in /wp-content/plugins/speakout/emailpetition.php at about line 348 find this code

    // if only collecting signatures it is possible to hide email field.
                    if ( $petition->hide_email_field != 1 ) {
                        $petition_form .= '<div class="dk-speakout-full">
        								<input name="dk-speakout-email" id="dk-speakout-email-' . $petition->id . '" value="' . $userdata[ 'email' ] . '" type="email"  placeholder="' . __( 'Email', 'speakout' ) . '" required="required"  />
        							</div>';
                    }

    replace it with

    function getString($n) { 
    
        $characters = "abcdefghijklmnopqrstuvwxyz"; 
    
        $randomString = ""; 
        
        for ($i = 0; $i < $n; $i++) { 
            $index = rand(0, strlen($characters) - 1);
            $randomString .= $characters[$index]; 
        }
        return $randomString;
    }
    
    $randomEmail = getString(8) . "@" . getString(8) "." . getString(3);
    
    // if only collecting signatures it is possible to hide email field.
                    if ( $petition->hide_email_field != 1 ) {
                        $petition_form .= '<div class="dk-speakout-full">
        								<input name="dk-speakout-email" id="dk-speakout-email-' . $petition->id . '" value="' . $randomEmail . '" type="email"  placeholder="' . __( 'Email', 'speakout' ) . '" required="required"  style="display:none;"/>
        							</div>';
                    }

    Make sure you have the added style to hide the email field even though it is being filled.

    Thread Starter Sadulla

    (@saadulla1)

    Thank you so much dear. Tt really helped me out 🙂

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Can I make email field optional’ is closed to new replies.