I’m discovering Roots at the moment and it looks promising. The concept of a theme wrapper however confuses me when working with custom forms. Where do I put my form processing code? With other themes, I throw the $_POST code on the same page-template above the <?php get_header(); ?>.
Any tips how to process my form data with Roots?
( I’m no fan of form plugins like Gravity Forms, so I do not intend to use them. )
Thanks for your swift reply. Putting the custom.php file in the Roots-Master root (or in the /lib subfolder for that matter) will lead to a 404 error. It will work however when I put the custom.php file in the WordPress root, but that’s not the proper way to build a theme or plugin.
I’ve been Googleing around to solve this 404 without success. I Hope you have the golden tip for me.
Edit 1: this is the code in the top of my form: action="<?php bloginfo('stylesheet_directory'); ?>/lib/custom.php"
Edit 3: The code from “Edit 1” does work in the TwentyTwelve theme. Somewhere, somehow bloginfo() breaks in Roots and that will cause a whole lot of trouble with a lot of plugins.
I made the custom.php file work with the following workaround:
In the Roots functions.php I’ve put the following line of code above the require_once lines: <?php define( 'ROOTS_URL', get_theme_root_uri() . '/' . get_template() ); ?>
Put the following code in the top of your form: <form id="form_name" name="form_name" method="post" action="<?php echo ROOTS_URL . '/custom.php'; ?>" enctype="multipart/form-data">
And Bob’s your uncle!
I dont’t know why functions like get_bloginfo() don’t work, but at the moment this is a working solution.
If anyone has a better solution, please let me know!