Title: Trouble adding tags on mandrill payload function
Last modified: August 21, 2016

---

# Trouble adding tags on mandrill payload function

 *  Resolved [evan3168](https://wordpress.org/support/users/evan3168/)
 * (@evan3168)
 * [12 years, 5 months ago](https://wordpress.org/support/topic/trouble-getting/)
 * I feel like I’m going crazy here with this basic function I want to fire on mandrill_payload
   to add some tags to my emails.
 * Here is my code:
 *     ```
       function dpg_mandrill_tag($message){
   
       	$message['tags'] = 'frankdougdog';
       	return $message;
       }
   
       add_filter('mandrill_payload', 'dpg_mandrill_tag');
       ```
   
 * When I send using that code, NO tags show up, let alone the one I tried to add
   there. I tried diving into the wpmandrill core php files to get a better understanding,
   but I am at a loss for why the tag won’t pass along. Help anyone?!
 * [http://wordpress.org/plugins/wpmandrill/](http://wordpress.org/plugins/wpmandrill/)

Viewing 7 replies - 1 through 7 (of 7 total)

 *  Plugin Author [MC_Will](https://wordpress.org/support/users/mc_will/)
 * (@mc_will)
 * [12 years, 5 months ago](https://wordpress.org/support/topic/trouble-getting/#post-4335330)
 * Hi Evan,
 * $message[‘tags’] is an array of arrays of arrays. Its values are $message[‘tags’][‘
   user’], $message[‘tags’][‘general’], and $message[‘tags’][‘automatic’].
 * You’re not supposed to modify the automatic tags (but you could if that’s what
   you really want.)
 * General tags are the ones added in the plugin’s settings page.
 * And ‘user’ are tags usually added by the wpmandrill_payload filter.
 * That say, try something like
 *     ```
       function dpg_mandrill_tag($message){
   
       	$message['tags']['user'][] = 'frankdougdog';
       	return $message;
       }
   
       add_filter('mandrill_payload', 'dpg_mandrill_tag');
       ```
   
 *  Thread Starter [evan3168](https://wordpress.org/support/users/evan3168/)
 * (@evan3168)
 * [12 years, 5 months ago](https://wordpress.org/support/topic/trouble-getting/#post-4335333)
 * Ah beautiful! I saw that the user, general, and automatic tags were merged in
   the core plugin so I thought by the time they reached mandrill_payload it was
   all one array.
 * Your adjustment to my function works perfectly, thank you so much for the help!
 *  Thread Starter [evan3168](https://wordpress.org/support/users/evan3168/)
 * (@evan3168)
 * [12 years, 5 months ago](https://wordpress.org/support/topic/trouble-getting/#post-4335334)
 * Hey Will gonna ask for your help just one more time… what would be the best way
   to pass an array of tags into the payload?
 *  Thread Starter [evan3168](https://wordpress.org/support/users/evan3168/)
 * (@evan3168)
 * [12 years, 5 months ago](https://wordpress.org/support/topic/trouble-getting/#post-4335338)
 * Ah nevermind, found a quick way to do it.
 *     ```
       function dpg_mandrill_tag($message){
   
       	$newtags = array( "frankdougdog","arri-alexa" );
   
       	foreach( $newtags as $tag ) {
   
       		$message['tags']['user'][] = $tag;
   
       	}
   
       	return $message;
       }
       ```
   
 * P.S. Sorry for the barrage of messages 🙂
 *  Plugin Author [MC_Will](https://wordpress.org/support/users/mc_will/)
 * (@mc_will)
 * [12 years, 5 months ago](https://wordpress.org/support/topic/trouble-getting/#post-4335376)
 * Hey,
 * I guess the best option will be to use the array_merge function.
 *     ```
       function dpg_mandrill_tag($message){
       	$message['tags']['user'] = array_merge($message['tags']['user'], array("frankdougdog","arri-alexa"));
       	return $message;
       }
       ```
   
 *  [Deepak Mahendru](https://wordpress.org/support/users/dpkmahendru/)
 * (@dpkmahendru)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/trouble-getting/#post-4335435)
 * Hi,
 * How can I get my code work using wpmandrill ?? Actually the problem is my mails
   are going to spam folder and I want them to go in Inbox… please help …thanks
 * add_filter(‘mandrill_payload’, ‘user_role_update’);
    function user_role_update(
   $user_id, $new_role ) { if ($new_role == ‘member’) { $site_url = get_bloginfo(‘
   wpurl’); $user_info = get_userdata( $user_id ); $to = $user_info->user_email;//
   To send HTML mail, the Content-type header must be set $headers = ‘MIME-Version:
   1.0’ . “\r\n”; $headers .= ‘Content-type: text/html; charset=iso-8859-1’ . “\
   r\n”; $headers .= “Organization: Organization \r\n”; $headers .= “X-Mailer: PHP”.
   phpversion() .”\r\n”;
 *  $headers .= “X-Priority: 1 (Highest)\n”;
    $headers .= “X-MSMail-Priority: High\
   n”; $headers .= “Importance: High\n”;
 *  // Additional headers
    $current_user = wp_get_current_user();
 *  $headers .= ‘From: ‘.$current_user->user_firstname.’ ‘.$current_user->user_lastname.’
   <‘.$current_user->user_email.’>,’;
    $headers .= ‘\r \n’; $headers .= ‘Reply-To:‘.
   $to; $headers .= ‘\r \n’; $headers .= ‘Return-Path: ‘.$current_user->user_firstname.’‘.
   $current_user->user_lastname.’ <‘.$current_user->user_email.’>,’;
 *  $subject = “Congratulations. You have been approved!”;
    $message = “”; wp_mail(
   $to, $subject, $message, $headers); }
 * }
    add_action( ‘set_user_role’, ‘user_role_update’, 10, 2); // add_action( ‘profile_update’,‘
   user_role_update’, 10, 2);
 *  Plugin Author [MC_Will](https://wordpress.org/support/users/mc_will/)
 * (@mc_will)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/trouble-getting/#post-4335436)
 * This article might be helpful:
 * [http://help.mandrill.com/entries/23317558-Why-are-my-emails-going-into-recipients-spam-folders-](http://help.mandrill.com/entries/23317558-Why-are-my-emails-going-into-recipients-spam-folders-)

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Trouble adding tags on mandrill payload function’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/wpmandrill_171717.svg)
 * [wpMandrill](https://wordpress.org/plugins/wpmandrill/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wpmandrill/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wpmandrill/)
 * [Active Topics](https://wordpress.org/support/plugin/wpmandrill/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wpmandrill/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wpmandrill/reviews/)

 * 7 replies
 * 3 participants
 * Last reply from: [MC_Will](https://wordpress.org/support/users/mc_will/)
 * Last activity: [12 years, 4 months ago](https://wordpress.org/support/topic/trouble-getting/#post-4335436)
 * Status: resolved