Currently, there are 0 users and 1 guest visiting this topic.
Author
Topic
#64997

I am a happy user of GDMail Queue lite, except that the queue filter seems not to be working now. I have the following code:

defined( 'ABSPATH' ) || exit;

add_filter('gdmaq_mailer_add_to_queue', 'custom__gdmaq_mailer_add_to_queue', 10, 3);
function custom__gdmaq_mailer_add_to_queue($add, $email, $type) {
  error_log("Queue tuning $add: " + $add?"true":"false" + " type: " + $type + " subject: ", $email->subject);
  $to_queue_types = array('bbpress_new_topic_in_forum', 'bbpress_new_reply_in_topic', 'bbpress_topic_edit', 'bbpress_reply_edit', 'buddypress_messages-unread');
  if ((in_array($type, $to_queue_types)) ||
  		(strncmp($email->subject, '[Ovni Owners] new post notification', 35) == 0) ||
  		(strncmp($email->subject, '[Ovni Owners] There is a new comment to', 35) == 0)){
    $add = true;
  }
  else {
  	$add = false;
  	}
  return $add;
}

Note I have a print to log statement at the beginning – the rest is irrelevant to this query. I am not seeing anything in the log.
I do see other logging using this technique. I am seeing emails processed by GD Mail Queue, either being queued or not but without the help of this filter being called. It used to work – methinks.

Can you advise, please?

Topic Information
Bug Report
7.4
5.5
3.8
Viewing 9 replies - 1 through 9 (of 9 total)
Author
Replies
  • #64998

    Hi,

    Every email passes through this filter, which is in the core of the plugin, it would not work without that. If the Intercept option is enabled, this filter is called for each email going through the wp_mail function.

    How are you loading your code? It is most likely loaded too late after any email call has been made already, so it doesn’t capture anything.

    Milan

    Dev4Press - Premium plugins for WordPress.

  • #64999

    It is in its own plugin with no other code.
    In addition to the code previously shown to you, it has the following comments:

    /*
    Plugin Name: Ovni Mail Queue Tuning
    Description: Refines behaviour of GD Mail Queue so that certain emails are queued while the rest are sent immediately
    Author: Tony
    	Version:	1.0		17 June 2019
    
    	History
    	Version:	1.0		17 June 2019		Initial version
    */

    The plugin is showing as activated and shows the description and version details. So I am confident it is being activated. But maybe I need to change the priority?

  • #65002

    Function ‘error_log’ depends on the error logging being enabled, if it is disabled in PHP, this function does nothing. So, I am not sure what to tell you, the plugin runs the filter for every email, so your code should be working. For error_log to work in WordPress, WordPress error logging needs to be enabled.

    Dev4Press - Premium plugins for WordPress.

  • #65006

    Error_log is working fine for me – I use it all the time.

    This evening I cleared caches and minified css/js in case the version with the inserted error_log statement was not being executed because of caching. Since then, I have started to get error messages as per the example below. Not sure if it is related. Looks like some kind of clash between a component of ‘gd’ bits and ‘bbp’ ( have bbp_style_pack active).

    WordPress database error Duplicate entry ‘262-3552’ for key ‘PRIMARY’ for query INSERT INTO oo_gdbbx_tracker (user_id, topic_id, forum_id, reply_id, latest) VALUES (262, ‘3552’, ‘168’, ‘14956’, ‘2020-12-28 19:37:24’) made by require(‘wp-blog-header.php’), require_once(‘wp-includes/template-loader.php’), apply_filters(‘template_include’), WP_Hook->apply_filters, bbp_template_include, apply_filters(‘bbp_template_include’), WP_Hook->apply_filters, bbp_template_include_theme_compat, BBP_Shortcodes->display_topic, bbp_get_template_part, bbp_locate_template, load_template, require(‘/plugins/bbpress/templates/default/bbpress/content-single-topic.php’), do_action(‘bbp_template_after_single_topic’), WP_Hook->do_action, WP_Hook->apply_filters, gdbbx_mod_tracking->latest_users_topic, gdbbx_core_db->track_topic_visit, d4p_wpdb_core->insert

    Your further guidance will be much appreciated.

  • #65007

    This is not related to the Mail Queue plugin. The error here is a known one, but, it is actually not the issue, because it uses a database feature to prevent duplicated tracking issues. There will be an update in GD bbPress Toolbox Pro to solve this, but it is not related to anything else.

    Dev4Press - Premium plugins for WordPress.

  • #65008

    OK thanks for that last.

    So it remains that I believe the queue filter is not working for me, as evidenced by the lack of logged messages and that the filter actions are not being obeyed. Can you advise what I should try? Plugin load order for filter vs GD Mail Queue? Filter priority up or down?

    thank you greatly

  • #65009

    Filter priority is not relevant. No matter the filter priority all functions hooked will be run, priority only determines the order it is run. Why is not working I have no idea, I use this filter on several websites, and a lot of other users do that too, and it works. And again, without that filter, the plugin would not work. The only reason for the filter not to work is if the email intercept is disabled in plugin settings, as I said in previous replies.

    Dev4Press - Premium plugins for WordPress.

  • #65020

    Mia culpa… in my error_log( ) call, I was trying to concatenate strings with + (as in JavaScript and C++) rather than a dot as required by PHP. This was causing the filter to fail without an error message. So no error log and, it seems, the subsequent batches of the email were not going to the queue.

    This has partially resolved my other query thanks. Sorry to have taken up so much of your time.

  • #65022

    OK, thanks for letting me know. Closing the topic now.

    Dev4Press - Premium plugins for WordPress.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘gdmaq_mailer_add_to_queue filter not being called?’ is closed to new replies.