Home Forums General Issues Call to undefined function have_rows() in mailer.php


Call to undefined function have_rows() in mailer.php

  • Hello,
    I try to load data from an ACF repeater inside a mailer.php script, which is called in the file footer.php in my WordPress template. have_rows() does work in the footer.php but not in the mailer.php as have_rows() seems to not be known in this file. I guess the issue is because of mailer.php gets called via a form as the form action. Can someone explain why this issue exists and how this could be fixed?

  • If you are using mailer.php as the form action, nothing in WP is include there and you will not be able to interact with anything related to WP, plugins or the DB.

    My first suggestion would be to use a form plugin that works with WP instead of working around it. Just so you know, I know where you’re coming from. I used to do the same thing. I don’t know the exact details of what you’re trying to do, so I can’t make any suggestions.

    Another alternative is to have the action to the page the form is on action="" and then include your mailer script on init

    add_action('init', 'php_mailer');
    function php_mailer() {
      // test to see if your form is submitted
      // if it is then include mailer.php
      // you might also need to redirect from here, I have not used mailer.php in years
      // not sure what else you would need to do here

    If you are using acf_form() to show the form then I would suggest using an acf/pre_save_post filter to send your emails and you can do that without needing to use a 3rd party script

    If you are using mailer.php in order to use SMTP there is also a plugin for that

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.