Support » Plugin: Constant Contact for WordPress » [Plugin: Constant Contact for WordPress] Custom Form HTML

  • Resolved Harry

    (@harmck)


    Hi,

    I’m just looking for some further explanation of using functions.php to generate slightly different html for the form. This is a quality plugin.

    Rgds,
    Harry

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Zack Katz

    (@katzwebdesign)

    You can modify the form by adding a function to your functions.php file, such as:

    add_filter('constant_contact_form', 'replace_this_with_that');
    
    function replace_this_with_that($form = null) {
    
    // The $form variable contains all the HTML of the form
    // and you can modify it however you want.
    $form = str_replace('this', 'that', $form);
    
    return $form;
    }

    Once you have your form in a function to edit, you can modify it to your heart’s content. Beyond what I’ve said is really a PHP lesson.

    I hope that helps!

    Cheers Zack,

    Thanks, I figured out a suitable workaround. Was just looking for the standard form the plugin generates so I’d know what to change. Unfortunately the form I was generating was part of a larger form, and I just needed to incorporate it into it.

    Thanks,
    Harry

    Hi Harry…

    I’d like to design my own forms as well. Could you tell me where you found “the standard form the plugin generates”?

    I’m working with a client that’s on goDaddy, so I may be forced to not use the Form Designer (tough host to work with on things like “whitelist your domain for ModSecurity”).

    Anyway, if you can elaborate on the earlier post, I’m very interested. I also have a project where it’d be good to gather info for both CC and PayPal in the same form.

    Thanks.
    —-
    Obbie

    Hi Obbie,

    I didn’t write a function to replace the output sadly, as I only need a very simple newsletter signup field. I simply saw where the script was posting to, and I used some PHP variables to build the URL to the post form, and I was able to customise this then.

    <form method="post" action="<?php echo 'http://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; ?>" id="constant-contact-signup" name="constant-contact-signup">
    
    <div id="mailingform">
    
    <input type="text" value="ENTER EMAIL ADDRESS" name="fields[email_address][value]" id="cc_email" onfocus="if(this.value=='ENTER EMAIL ADDRESS') this.value='';" onblur="if(this.value=='') this.value='ENTER EMAIL ADDRESS';" />
    
    <input type="hidden" name="cc_newsletter[]" id="cc_newsletter-4" value="4" /> 
    
    <input type="hidden" id="cc_referral_url" name="cc_referral_url" value="<?php echo bloginfo('siteurl').'/thank-you-for-subscribing/'?>" />
    </div>		
    
    <button id="mailingsubmit" name="constant-contact-signup-submit" value="Signup" class="button submit"></button>
    </form>

    I’m sure from here you could incorporate your PayPal code, and expand on the fields being posted to Constant Contact.

    Good luck,

    Harry

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Plugin: Constant Contact for WordPress] Custom Form HTML’ is closed to new replies.