I am not aware of how many users there are of NL-PHPMail who also use WordPress, because a lot of WordPress users choose to use the contact form instead.
However, in the case that some people do use this script and would like to use it with a WordPress theme, so that the success page doesn’t look like a crummy basic page or a header/footer file version of your theme that you have to update manually and separately – use your WordPress theme with the script instead!
NL-PHPMail can be downloaded from CodeGrrl.
Edit the settings in nlphpmail.php how you like, but now pay close attention to what needs to be changed. You will see a section here:
// Path to header and footer (don't know what these are? See this tutorial: http://codegrrl.com/tutorials/headers-and-footers) // This can be a relative path (like 'header.php' if it's in the same directory), or an absolute path (e.g. '/home/myusername/public_html/myfiles/header.php'. // DO _NOT_ USE A URL (e.g. http://site.com/header.inc) - THIS WILL NOT WORK. // If you aren't using headers and footers, do not edit this part. $header_file = 'header.php'; $footer_file = 'footer.php';
You might assume that putting your WordPress headers will work but they will NOT work.
Make sure there is nothing between the apostrophes:
$header_file = ''; $footer_file = '';
There is a section that reads DO NOT EDIT ANYTHING BELOW. However, we must edit a part under here in order to allow the theme to work. Find the following in the document.
if (!empty($header_file) && file_exists($header_file)) @include $header_file; else echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <title>Feedback Form</title> </head> <body>'; echo $message; if (!empty($footer_file) && file_exists($footer_file)) @include $footer_file; else echo '<p style="text-align: center"><a href="http://codegrrl.com/" title="NL-PHPMail from CodeGrrl.com"><img src="phpmail.gif" alt="Powered by NL-PHPMail" title="Powered by NL-PHPMail" style="border: 0 none;" /></a></p> </body></html>';
You will notice there are two sections. A simple explanation of this is that if you are not using header and footer files, this is the coding that will display before and after the success/error messages. It is very basic.
You can of course edit this to your liking, however, to make the script work with a WordPress theme you must remove the coding so that it looks like this:
if (!empty($header_file) && file_exists($header_file)) @include $header_file; else echo ''; echo $message; if (!empty($footer_file) && file_exists($footer_file)) @include $footer_file; else echo '';
Again we are deleting everything in between the apostrophes. Now you simply have to add in the WordPress includes that will display your theme.
The following code is to be placed at the very top of the document. Right at the beginning.
You need to change ABSOLUTEPATH/WORDPRESS to your absolute path and then, the folder where WordPress is installed. (You might not have it installed in a separate folder, in which case you would just put your absolute path. Visit this tutorial on WP themes with PHP pages if you are stuck.)
<?php require('/ABSOLUTEPATH/WORDPRESS/wp-blog-header.php');?>
<?php get_header(); ?>
<?php get_sidebar(); ?>
You may remove <?php get_sidebar(); ?> if you don’t have a sidebar or if it is already included in your header file.
The following codes goes at the very bottom of the document, right at the end.
<?php get_footer(); ?>
Save the file, and upload it to your server. If you test one of the forms on your website and send a dummy form, you should see the success (or error!) page working with your theme.