• Resolved jacobcoens

    (@jacobcoens)


    Hi,

    I would like to have the possibility to manipulate the arguments for send an e-mail. For this, in includes/wp-mail.php you could add the following just before sending the email (line #209 in plugin version 1.0.1):

    $args = apply_filters( 'wp_sendgrid_args', $args );

    This would enable me to disable the subscription tracking for a specific website that uses our company-wide SendGrid account by using the code below:

    /**
     * Disables SendGrid subscription tracking
     */
    function filter_wp_sendgrid_args( $args ) {
    	$headers = array();
    	$headers['filters']['subscriptiontrack']['settings']['enable'] = 0;
    	$args['x-smtpapi'] = json_encode($headers, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP);
    
    	return $args;
    }
    
    /**
     * Disable SendGrid subscription tracking
     */
    add_filter( 'wp_sendgrid_args', 'filter_wp_sendgrid_args' );

    http://wordpress.org/extend/plugins/wp-sendgrid/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Will Anderson

    (@itsananderson)

    I actually just now saw this request, but as luck would have it, I just released a new version of the plugin that adds that filter. I had a similar request over on GitHub, which prompted me to add the filter.

    When you get a chance, check that you can do what you’re wanting with version 2.0 and let me know if it works. If so, I’ll resolve this thread.

    Plugin Author Will Anderson

    (@itsananderson)

    Actually, I forgot to mention. You can also use the ‘wp_sendgrid_xsmtpapi’ filter to get at the X-SMTPAPI array directly. Then just do something like the following:

    /**
     * Disables SendGrid subscription tracking
     */
    function filter_xsmtpapi( $xsmtpapi ) {
    	$xsmtpapi['filters']['subscriptiontrack']['settings']['enable'] = 0;
    	return $xsmtpapi;
    }
    
    /**
     * Disable SendGrid subscription tracking
     */
    add_filter( 'wp_sendgrid_xsmtpapi', 'filter_xsmtpapi' );

    Even easier 🙂

    Plugin Author Will Anderson

    (@itsananderson)

    Closing this thread. Feel free to reopen if this solution doesn’t solve your problem.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Request: Add filter for manipulating arguments’ is closed to new replies.