Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function cta_send_notification( $new_status, $old_status, $post ) {
- $sxss=get_post_type();
- if(
- 'publish' === $new_status &&
- 'publish' !== $old_status &&
- $sxss == 'cta'
- ) {
- function postToDiscord($message)
- {
- $data = array(
- "content" => $message,
- "username" => "CTA PING BOT",
- );
- $curl = curl_init("https://discordapp.com/api/webhooks/idchannel/key");
- curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
- curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data));
- curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
- return curl_exec($curl);
- curl_close($curl);
- }
- $postid =get_the_ID();
- $taste=get_the_title($postid);
- global $post;
- // get post meta
- $pstmt1=get_post_meta( $postid, 'wpcf-fleetformat', true );
- $message="**";
- $message.=$taste;
- $message.=' **
- ```
- --------------------------------------------------------------
- Location: UALX-3
- Datetime: 10.08.18 20:00 ET
- FleetFormat: '.$pstmt1.'
- FC: TBD
- --------------------------------------------------------------
- ```';
- postToDiscord($message);
- }
- }
- add_action( 'transition_post_status', 'cta_send_notification', 10, 3 );
Add Comment
Please, Sign In to add comment