Title: Attachment support ( code included )
Last modified: October 19, 2018

---

# Attachment support ( code included )

 *  [disagree](https://wordpress.org/support/users/disagree/)
 * (@disagree)
 * [7 years, 7 months ago](https://wordpress.org/support/topic/attachment-support-code-included/)
 * I’m using this plugin to send my own slack notifications, so I’m using the `$
   GLOBALS['wp_slack']->notifier->notify( new WP_Slack_Event_Payload( $payload ));`
   method to submit the payload.
 * It would be great if you could take `attachments` into account when sending the
   payload. To make this work, the only change needed is in the file `includes/event-
   payload.php` :
 *     ```
       	public function toJSON() {
       		$payload = array(
       			'channel'      => $this->setting['channel'],
       			'username'     => $this->setting['username'],
       			'text'         => $this->setting['text'],
       			'icon_emoji'   => $this->setting['icon_emoji'],
   
       			/**
       			 * @todo icon_emoji with ability to select it in setting.
       			 */
       		);
       		if(array_key_exists('attachments', $this->setting)){
       			$payload['attachments'] = $this->setting['attachments'];
       		}
       		return json_encode($payload);
       	}
       ```
   
 * It’s basically moving the current payload into a `$payload` var, and then if `
   attachments` exists, it adds it to it. That’s all.
    -  This topic was modified 7 years, 7 months ago by [disagree](https://wordpress.org/support/users/disagree/).

The topic ‘Attachment support ( code included )’ is closed to new replies.

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

 * 0 replies
 * 1 participant
 * Last reply from: [disagree](https://wordpress.org/support/users/disagree/)
 * Last activity: [7 years, 7 months ago](https://wordpress.org/support/topic/attachment-support-code-included/)
 * Status: not resolved