0

I'm using the SendGrid PHP library to send transactional emails on submission of new posts by the user, a simple submission received.

In the admin, it works perfectly. On the front end I get a class not found error.

As a test I threw this into functions.php

require( get_stylesheet_directory() . '/includes/vendor/sendgrid/sendgrid-php.php' );

if ( ! class_exists( 'SendGrid' ) ) {
   echo "Class Does Not Exist";
}

In the admin, it doesn't echo the string. But on the front end, it does. Is there something that could be blocking the class being initiated on the front end that isn't present in the admin side?

| improve this question | | | | |
  • Have you included the composer autoloader? I see a vendor folder there which suggests you pulled the library in via composer – Tom J Nowell Oct 15 '16 at 4:54
  • I'm not using the composer version, instead loading it in the first line of the code above as documented in the library. – Picard102 Oct 17 '16 at 3:47
  • Then where did the vendor folder come from? You must have a composer autoloader that's only being loaded on the admin side and not the frontend – Tom J Nowell Oct 17 '16 at 11:51
  • I named the containing folder vendor. It's not from composer. – Picard102 Oct 17 '16 at 19:27
  • Ah, that's confusing. Are you filtering on any URLs? Can you confirm the file being included is the same on both back and front end? – Tom J Nowell Oct 18 '16 at 15:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.