Advertisement
Guest User

Different Field Names for Flamingo w/ Contact Form 7

a guest
Oct 25th, 2013
340
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.67 KB | None | 0 0
  1. /*
  2. This paste is for editing the fields that the Wordpress Flamingo plugin interprets as name and subject from the Contact Form 7 plugins' form submissions.
  3.  
  4. To make the adjustment, you'll need to edit the PHP code in the Flamingo module that's a part of Contact Form 7.
  5.  
  6. To do this, go to "Plugins" --> "Editor". Then in the top right hand corner, select Contact Form 7 as the plugin you want to edit. Click Select.
  7.  
  8. You're looking for "contact-form-7/modules/flamingo.php". Once you click on that file, scroll down close to the bottom, but not all the way. You're looking for the following lines of code:
  9. */
  10.  
  11. $email = isset( $posted_data['your-email'] ) ? trim( $posted_data['your-email'] ) : '';
  12. $name = isset( $posted_data['your-name'] ) ? trim( $posted_data['your-name'] ) : '';
  13. $subject = isset( $posted_data['your-subject'] ) ? trim( $posted_data['your-subject'] ) : '';
  14.  
  15. /*
  16. These lines set what field name variables that Flamingo is looking for to set the values for the email, name and subject. Simply change the variable in both places of the line for each area that you're trying to adjust.
  17.  
  18. In my case, I created a form where people are entering their first name and last name in different fields.
  19.  
  20. My new code for those three lines looks like this:
  21. */
  22.  
  23. $email = isset( $posted_data['your-email'] ) ? trim( $posted_data['your-email'] ) : '';
  24. $first_name = isset( $posted_data['first-name'] ) ? trim( $posted_data['first-name'] ) : '';
  25. $last_name = isset( $posted_data['last-name'] ) ? trim( $posted_data['last-name'] ) : '';
  26. $name = $first_name . " " . $last_name;
  27. $subject = isset( $posted_data['your-subject'] ) ? trim( $posted_data['your-subject'] ) : '';
  28.  
  29. /*
  30. This way, Flamingo still interprets their first and last name as one name, but I get the variables to use in my email in different places, such as "Hello [first-name]" in the auto-receipt email that gets sent to visitors when they submit the form.
  31.  
  32. In my case, I didn't need to change the subject variable. Instead, I used the Contact Form 7 Modules plugin to insert a hidden field into the form that sets the subject to a static value.
  33.  
  34. However, if you wanted to change it to something else in your form, like "company-name" for a field [company-name], just modify the code above in the appropriate places.
  35. */
  36.  
  37. // The original line of code.
  38. $subject = isset( $posted_data['your-subject'] ) ? trim( $posted_data['your-subject'] ) : '';
  39.  
  40. // The modified line of code.
  41. $subject = isset( $posted_data['company-name'] ) ? trim( $posted_data['company-name'] ) : '';
  42.  
  43. /*
  44. There, you've just changed it so that Flamingo interprets whatever your visitors put in the company-name field as the subject of the message.
  45. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement