Created a plugin for posting to a discord. Separate record type, with its own dopics. I tested the output of fields in a loop (the output of all fields in archive-cta.php) is output. the plugin does not work. That is - post fasting, but doppolya does not pull. get_the_title ($ postid) pulled out without problems.
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 ); I suspect that the fields are written in the database after publication. and they still do not get into the database, and I try to get them
function cta_send_notification( $post_id ) { if ( wp_is_post_revision( $post_id ) || get_post($post_id)->post_status != 'publish' ) { return; } function postToDiscord($message){ $data = array( "content" => $message, "username" => "CTA PING BOT", ); $curl = curl_init("https://discordapp.com/api/webhooks/айди/кей"); 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); // get post meta $pstmt1=get_post_meta($postid, 'wpcf-date-time', true ); $message="**"; $message.=$taste; $message.=' ** ``` ------------------------------ ID '.$postid.' Title '.$taste.' post meta : '.$pstmt1.' ------------------------------ ```'; postToDiscord($message); } add_action( 'save_post_cta', 'cta_send_notification', 99999, 1 ); Remade under save_post. The result is the same. Aidi and title normally pulls. Doppol does not pull