• I’m creating a simple PHP/AJAX contact form in my WordPress theme. The ACTION is “/php/mailer.php

    The problem is, when I submit the form, I get an UNDEFINED error for all WP functions in the mailer.php file (e.g. wp_mail, get_site_url, etc).

    These functions work fine anywhere else. The wp_mail function, for example, will send email if I put it in a template file like “Contact Us”, but when it’s placed in mailer.php and retrieved by a form, I get the undefined error.

    What’s going on here???

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    Thread Starter aofolts

    (@aofolts)

    The file isn’t outside WordPress, though. It’s in my theme folder.

    I’m also having the same problem when I try to create my own custom RSS feed. I have the following code in functions.php:

    remove_all_actions('do_feed_rss2');
    
    function zion_rss() {
    
    	load_template( get_template_directory_uri() . '/feed-rss2.php', 10, 1);
    
    }
    
    add_action('do_feed_rss2','zion_rss');

    I added the feed-rss2.php file to my theme folder, and just removed the author tag (no other changes). But when I view the feed, I’m getting another undefined error:

    <br />
    <b>Fatal error</b>:  Call to undefined function feed_content_type() in <b>/home4/palokoff/public_html/pennavechurch.org/wp-content/themes/Penn Ave Theme/feed-rss2.php</b> on line <b>8</b><br />

    Functions.php calls WordPress functions just fine, so why would files in the same folder (mailer.php, feed-rss2.php, etc) get undefined errors?

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘All WP functions UNDEFINED when creating PHP contact form’ is closed to new replies.