Ilene Prusher, hired Jack as a IT Consultant

“Jack helped me develop a website that I feel incredibly proud of, and he was very patient in sitting with me to explain how all the software works so that I could update it myself in the future.

Jack’s knowledge of the IT/web world is extensive. There is no question that I asked him that he didn’t know how to answer. He was extremely professional and pleasant to work with. I continue to consult Jack when I have questions and he’s been incredibly helpful and responsive. I recommend working with him without hesitation!”

Why Use WordPress? The Long Reason

WordPress is a CMS (Content Management System). In the late 90’s, when I first began building websites, you used to have to create a separate page for every page on your site. One would think that that follows a certain logic. But if you consider this further there are many elements on each page that repeat themselves over and over again in a site: the header, the menu, the footer, etc, etc, etc… Why should web developers waste time rebuilding those elements for each page, and why should companies have to pay for that time?

When databases came into the picture building websites got much easier. You could store the content that changed regularly in the database, and build a template that had all the recurring elements inside. Each page that loaded got its recurring elements loaded as well as the unique content was pulled in from the database. Thus was born the CMS.

Many web development companies came and built their own content management systems, which was fine. The problem was that if you wanted to change to another web development company, you couldn’t. You needed someone who could understand what the previous company had done. And not all companies were willing to share their proprietary systems.

Thus was born the Open Source revolution – The democratization of code.

As WordPress developed, a whole community developed around it; a community of developers and designers, all using one standard – WordPress. And we all work together to develop that standard to be the best it can be.

So now, instead of having to rely on one company to develop its proprietary CMS, which costs the company time and money to develop, we can now be part of a greater community of highly skilled developers. A team that works to continuously develop its product, that they themselves use, but now have a whole team to work with. And the WordPress community holds to the standard…

CODE IS POETRY

On the bottom of every page of the WordPress.org site are those three little words. Who wouldn’t want to use a system that was built striving for that standard of quality? To contemplate every line of code, as a poet does a poem, to make sure it is performing as best it can…

How To Integrate Salesforce With Cforms (and have multiple Salesforce Web to Lead forms in WordPress)

If you use Salesforce and you have a WordPress powered site you may be frustrated. Salesforce is a wonderful tool for managing your customers and potential leads. WordPress is the best CMS out there today (I am a little biased, but it’s true). So why can’t they play together?

There IS a solution out there now… The WordPress-to-lead for Salesforce CRM Plugin by Yoast is a noble effort. It’s easy to use, which is more than I can say for the instructions I will be giving below (but even if you’re not a coder, you should be able to follow). The problem is that it only offers one form.

But what if you are running multiple campaigns? What if you need different forms? You can use the Web to Lead custom forms that Salesforce offers, but if you want to have required fields, you’ll need to code special JavaScript to validate those forms… That’s not a very good solution either.

Also, what if you want to keep a backup of the leads. The Web to Lead forms have a limit of 500 leads a day. While they assure you that you will be emailed the rest of the leads so you can input them yourself, you may want a central place to track your leads aside from Salesforce.

This is where Cforms II comes in. Cforms is my favorite WordPress forms plugin. It offers a beautiful GUI backend, many features, themes and even form tracking. Wouldn’t it be great if you could combine the best WordPress form plugin with the best CRM in town?

Note:

Once you make these adaptations you should be aware that EVERY form you create with Cforms on your site will try to submit the information to Salesforce. If you would like only SOME of your forms to be submitted see the appendix at the end of the post.

Step 1 – Hack Cforms

I often hack plugins. It is laborious, trying to figure out the inner workings of certain plugins. They tend to be poorly commented and many best programming practices are avoided. In contrast, Cforms is beautiful. Not only is it understandable as code; but the author created a file: “my-functions.php” whose sole purpose is to allow other coders to add functionality to the plugin without having to hack. This is what we will be “hacking”.

Find the following block of code:

 

And replace it with this:

 

Explanation:

Initially, I thought that the “Send form data to an alternative page” option under “Core Form Admin/Email Options” but whatever I did, the forms, when submitted, got stuck on the dreaded “One moment please…” Ajax message. The answer was submission via cURL (ask your neighborhood coder to explain). In addition there is some data processing involved so that the form contents will be understood by Salesforce.

Step 2 – The Form

The next stage is building your forms in Cforms.

Click to enlarge

I am assuming that you’ve already built some web-to-lead forms in Salesforce, and you like the idea of having a form engine running them with form validation and database tracking. If you haven’t yet, please create a form in Salesforce. It is not easy to figure out how to do this, and the salesforce help sometimes omits important information, not to mention needing an account to access the help. So getting the code for a web-to-lead form warrants a post of it’s own, but that will have to be for another time.

Once, you have the code for the form go through it and add to your Cforms form a field for each field that you have in the Salesforce form (if you add extra fields I don’t know if Salesforce will process that information).

One thing to keep in mind when doing this is that you should make sure to name the fields EXACTLY as they do. Each field in the Salesforce code begins with a

For example:

<label for="company">Company</label><input id="company" maxlength="40" name="company" size="20" type="text" /><br>
<label for="first_name">First Name</label><input  id="first_name" maxlength="40" name="first_name" size="20" type="text" /><br>

So you want to call your first Cforms field “Company” and your next one “First Name”.

When you’re done adding all the fields there are a few more “hidden” fields that you will need to add:

  1. In position #1 add a field.
  2. Under “Type” change the field from “single line of text” to “hidden field”.
  3. In the “Field Name” type ‘oid|’ and  then without spaces your Salesforce organization ID number.

To find your oid refer back to your form code provided by Salesforce. About 10-15 lines down you should see two lines like this:

<form action="<a href="https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8">https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8</a>" method="POST">
<input type=hidden name="oid" value="XXXXXXXXXXXXXXX">

Where instead of the letter X you’ll see a string of numbers and letters (I’ve counted 15 numbers, it may vary, but probably not). That’s your Salesforce organization ID.

If you are running campaigns and you want the form to be added to one of those campaigns, you will need to add the Campaign ID as well as a hidden value.

In your Salesforce code look for something like this:

	<label for="Campaign_ID">Campaign</label>
	<select  id="Campaign_ID" name="Campaign_ID">
		<option value="">--None--</option>
		<option value="XXXXXXXXXXXXXXX">Contact us - Website</option>
	</select>

There probably will be more <option> tags. Choose the campaign you would like the Cforms form to add the lead to and copy the ‘value’ (whatever is in between the quotation marks <option value=”XXXXXXXXXXXXXXX”> ).

Then add another hidden field to your Cforms form. Call it ‘Campaign_ID|’ then without spaces your Salesforce campaign ID number (same process as above).

Make sure to update the form when you are done.

Step 3 – We’re almost done

Click to enlarge

There is one more step to take. Underneath your form in Cforms there are options. Open up “Core Form Admin / Email Options” and you’ll find an option: “Use custom input field NAMES & ID’s”. By default, Cforms uses generic field names and ID’s for the input fields. Salesforce does not understand these names. By checking this box it is ensuring that Salesforce will be able to understand the information you are sending it. Make sure to update the form again and you’re good to go.

Appendix – or “What if I don’t want ALL my forms to be submitted to Salesforce?”

As I mentioned above, once you make these adaptations you should be aware that EVERY form you create with Cforms on your site will try to submit the information to Salesforce. If you do not want this to happen there are a few more lines of code that need to be added to “my-functions.php”.

Before we make the changes you’ll need to know the ID of the forms you want submitted. If you go to the “Form Settings” page you will see at the top a form navigation system to navigate between forms.

On the right you’ll see numbers in white ovals and one in a blue circle. Each of those number correspond with a different form and that number is the form ID. Navigate to the form you want, and then see which number is in blue.

Next: Open up “my-funtions.php” and find the line

$form   = $cformsdata['data'];

After that line insert the following code:

if ( $formID == '3'){

Replace the number ‘3’ with the ID of the form you want sent to Salesforce. If there are several forms you want sent then use this code instead:

if ( $formID == '3' || $formID == '4' ){

Again, replace the numbers to the corresponding numbers of the forms you want send to Cforms. For each form you want included add another || $formID == ‘N’ before the closing bracket.

WAIT! You’re not done yet!!! If you leave it as-is you will break Cforms.

Find the end of the function. It will end with a curly bracket.

fclose($fp);

}

between the fclose($fp); and the } add another curly bracket ‘}’ like so:

fclose($fp);

}

}

If you skip this stage you will probably break Cforms. And NOW, don’t forget to save the changes you’ve made.

NOW you’re done!

Questions? Comments? Please feel free to ask below!

Hannah Brown, hired Jack as a Graphic/Web Designer

“Jack Reichert helped me get my blog up and running, as well as designing and adding features. He was great fun to work with, answered my questions thoughtfully and thoroughly, gave me many new ideas, was punctual and charged a reasonable fee. I highly recommend him to anyone else interested in blogging or creating a website.”

Kobi (Ian) Cooper, hired Jack as a Graphic/Web Designer

“Jack has been working on developing my website – www.tourguideofisrael.com – and while it is still a work in progress (due to delays on my end, not his), to this point Jack has been incredible. What I like best is that he always gives me options of how things could look and allows me to decide on the look and feel of the site. He is also very patient with me as I put this together, both from a stylistic and content standpoint. He is also very reliable – every time I send something to him to update he gets it up almost immediately, allowing me the comfort of knowing that when I want to update the site in real-time, he will be there for me. Even better, we have talked about his showing me how to update key sections myself so that at some point I could become self-sufficient with it. Needless to say, I have been very satisfied with our working relationship thus far.”