libreform / wp-libre-form

Easy native HTML5 forms for WordPress. Version 1.5 is unmaintained, but works without issue. 2.0 has been rewritten from the ground, and can be found at https://github.com/libreform/libreform
https://wordpress.org/plugins/wp-libre-form
GNU General Public License v3.0
67 stars 27 forks source link

Feature proposal: Better email handling and templates #37

Closed jpeltoniemi closed 5 years ago

jpeltoniemi commented 7 years ago

The default template for email is, well, ugly. I guess the idea is that you create your own email action or template to suit your needs. However, it isn't exactly just plug-and-play.

I propose a template system that lets you select a template in the form editor in a similar manner you would select a template for a page. Of course this feature should be easily disableable by a filter in case someone wants to do things differently.

I need templates in my current project and template support is definitely going to be there. If you find this useful, I could try to invest some extra time into considering a wider audience.

Niq1982 commented 7 years ago

I have been thinking a few times if I should propose this myself. Would it be consirable to use the template hierarchy kind of structure? ie. put wplf-mail.php to your theme dir and it will be used to send the mails. Or wplf-mail-$id.php or wplf-mail-$slug.php if you need different templates for different forms.

That way it could be easily included in theme starting points and version controlled etc. and wouldn't interfere with the basic action, if someone prefers to use the original way. I can think of numerous of use cases if you could get any data from WP to get included in mail response or add some kind of logic inside the template before sending it.

anttiviljami commented 7 years ago

Yes. The current email thing is just for convenience, not ready for customers to use. Definitely preferred if you always implement your own pretty html emails, instead of the current debuggy ones.

I remember a while back somebody already built their own template system and PR'd it, but I wasn't quite happy with the UI there and nobody championed the feature from there on.

I'd appreciate it if someone contributed a pretty way of creating email templates for WP Libre forms. Definitely a candidate for core inclusion.

jpeltoniemi commented 7 years ago

@Niq1982 Not so sure about that. Might be just me but I loathe hard-coded ids because they could change any time. What I'm after would act fine just as-is, but would also be easily extendable - just like page templates are.

@anttiviljami I was thinking that I just add a metabox for selecting a template file, that is populated from a specific folder in theme(and child theme!). Shouldn't be more complicated than that. I'll at least do a crude version for this project and if it seems good enough for others to finalize it, I'll make a pull request.

Actual template editor in wp-admin wouldn't be too high priority, at least on my list. If you know your stuff, you won't probably mind editing template files and on the other hand if you don't know your stuff, you probably can't use a fancypants template editor anyway and have to hire someone who will then agonize over the editor not behaving like any sensible person would expect.

Also, for me the biggest strength of WPLF for me right now is its simpicity and the no bullshit-clause. I think you'd have to really put some work into it before it would seem even a little appealing next to Gravity Forms and whatever else are the top form plugins.

k1sul1 commented 7 years ago

I'm pretty sure no one actually uses IDs in template files, but that's possible using the default hierarchy in WP.

That being said, I'd probably rather select the template from a dropdown similar to the page template dropdown:

dropdown

Using hierarchy is good when you don't want to give any (unnecessary) control to the client, but most likely clients would like to choose the email template they're going to use.

Currently no one without decent understanding in HTML and CSS isn't going to touch the forms, but that is probably going to change in the future. Someone just has to have time to build a form builder on top of this.

jpeltoniemi commented 7 years ago

@k1sul1 Some of my old maintenance/upgrade jobs disagree.

Horror stories aside, that's the exact way I was thinking this should be done. Simple and efficient and will probably be a decent worksforme-solution for most.

k1sul1 commented 5 years ago

I guess this issue is stale. Reopen if necessary.