Add Contact Form to Directory Listings

Hi,

I am using the Directory plugin. It's working great. I've added my own style and also customized some to meet my needs.

Now,
I'd like to add a "Contact Company" form.

The form will be attached to every listing.
The form will consist of 5-6 fields.
The fields will not change.

Upon form submission, desired functionality includes:

1. ability to distinguish the originating listing
2. manage e-mail recipient(s) based on originating listing

** It's also critical that all new listings created automatically inherit this functionality requiring no manual attention. The "contact this company" form will just exist as part of each listing widget.

I'm extremely knowledgeable in PHP and already have an idea of how to accomplish this the custom route, while referencing the WP codex.

Although, I'm still some-what of a WP novice. So, I'm wondering if anyone can provide any advice / recommendations / guidance / direction to help me accomplish my objectives the easiest/quickest way possible :slight_smile:

Thanks!!
Eric

  • Alexander

    @ericm,

    Sure I can help give some insight here. Could you perhaps give a bit more context on how you'd like this implemented?

    The 5-6 fields that don't change can easily be done with html and php knowledge. But where exactly do you want them? You mentioned widget, so should they be displayed in the listing widget only? Or do you want it to appear at the bottom of each listing page?

    Let me know where you want it, and perhaps how it will be used and I can provide for information, as there are a few ways it could be done.

    Also, I'd recommend looking into using ajax actions. They're a great way to handle form submissions. It requires a bit of javascript to submit your form for you, but it's great for the user experience, and is very easy to implement on the PHP side.

    Best regards

  • ericm

    Hi Alexander,

    Thanks for the response.

    It sounds like you recommend a custom approach, rather than integrating some additional plugin. That's what I was leaning towards too.

    Some more information:

    - I'm displaying the listings (their titles only) in a table structure.
    - Each one is a click-able link.

    Once a listing is clicked, I want to display the submission form inside a pop-up (using the Pop-Up plugin). Yes, ajax actions are desired and I am quite experienced in this area. Although, jQuery seems to be WordPress' library of choice. I come from a Dojo background. But, I'm not too worried..

    Oh, please disregard my previous use of the word "widget" - I'm not using wordpress widgets here.

    If there is a way for us to communicate privately, I'd love to show you the working project.

    -Eric

  • Alexander

    Sounds good!

    Well, it sounds like you know what you're doing for the most part. Is there perhaps anything specific I can help with for your code? Here are just a few thoughts

    If you're not using a widget, I'd advise working with the front end template files provided by Directory. You can find these in directory/ui-front/general

    In the template you will probably need to setup a hidden input with a listing ID supplied. Then your ajax action can lookup the email address associated with the post. To get this ID in the template, you can use

    get_the_ID()

    Sure, I wouldn't mind taking a look. If you'd like to get in touch, just message me through the contact form. Choose "I have a different questions" then include my name in the subject "Alexander Rohmann"

    Best regards

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.