Home›Forums›Feature Requests›PTA Member Directory and Contact Form – Feature Requests›Add a "class" to the headings above the contact form
- This topic has 2 replies, 1 voice, and was last updated 10 years, 1 month ago by Martin Taylor.
-
AuthorPosts
-
-
November 23, 2014 at 11:06 AM #1745Martin TaylorGuest
Hello again.
I’ve now started to use the Contact Form on a separate page. There are two headings above the form – an “h2” with the location name and an “h3” with the name of the person the message is being sent to. Neither of these has a class on it, and they’re outside the form, so I can’t target them with any CSS.
Maybe the easiest thing to do is to move them inside the form?
Incidentally, there are also a couple of hidden “input” elements before the form – a “nonce” and a “referer” which don’t look right where they are.
Martin
-
November 23, 2014 at 12:12 PM #1746Stephen SherrardKeymaster
You are correct as far as the headers on the contact form… I should have added some classes to those, or a wrapper div at least, with the last update… just super busy with projects here, so put that last update out quickly and didn’t look at the contact form function.
I’ll see if I can push out an update today with a div wrapper around that contact form, as well as some classes for those headings.
However, there are also filter hooks in place to allow other plugins or themes add content before and after the form (including before those headings are output). So, you could add a wrapper div of your own choosing around the contact form without modifying the plugin by adding a couple really simple hooks and functions to your theme’s functions.php file. This is all you would have to do to add your own div wrapper:
function ptamdcf_add_div_start($html, $id, $location) { return '<div class="ptamd_contact_form">'; } add_filter('pta_member_before_contact_form', 'ptamdcf_add_div_start', 10, 3); function ptamdcf_add_div_end($form_html, $id, $location) { return $form_html . '</div>'; } add_filter('pta_member_before_contact_form', 'ptamdcf_add_div_end', 10, 3);
Also, the nonce and referrer fields are necessary for security and best practices. Those are generated by the built-in wordpress function wp_nonce_field, and the location in my script is actually inside the form, but it looks like I didn’t set the optional third echo argument to false, so it’s echoing those fields before the rest of the form is returned. It still works fine that way, but I’ll change that in the new update.
- This reply was modified 10 years, 1 month ago by Stephen Sherrard.
-
November 23, 2014 at 2:24 PM #1748Martin TaylorGuest
Thanks! I did see those filters and had used them, but having it built in will be great.
And I finally worked out the piece about the nonce echo, but you’d got there first. Thanks for making the update so quickly.
Martin
-
-
AuthorPosts
- The topic ‘Add a "class" to the headings above the contact form’ is closed to new replies.