devomacdee
Forum Replies Created
Viewing 2 replies - 1 through 2 (of 2 total)
-
Forum: Developing with WordPress
In reply to: custom metabox data not being available in $_POST dataSorry, I also wanted to point out, that my nonce field is undefined/null in the save method. From everything I’ve seen this looks like how it should work, and I can echo that it’s there when I render the meta boxes.
Forum: Developing with WordPress
In reply to: custom metabox data not being available in $_POST dataoh, ok. I did just run this and only this plugin, and
error_log('$_POST: ' . print_r($_POST, true));this was just printing an empty array. I do have another plugin file as well, that also hooks into thesave_postsaction.public function send_post_data($post_id, $post, $update) { // Check if this is a new post creation, not an update if ($post->post_status === 'publish') { $post_title = $post->post_title; $post_url = get_permalink($post_id); $post_author = get_the_author_meta('display_name', $post->post_author); $merchant_id = get_option('payper_settings_option_name')['merchant_id_3']; // $price = get_option('payper_settings_option_name')['price_2']; $category = get_the_category($post_id); $api_key = $this->get_payper_api_key(); if (empty( $api_key ) || !isset( $api_key ) || is_null( $api_key ) || $api_key === false) return; // $price = get_post_meta($post_id, 'payper_post_price', true); // error_log('get_post_meta: ' . get_post_meta($post_id)); $price = "0.02"; // $metas = get_post_meta($post_id); // foreach($metas as $key => $value) { // error_log('get_post_meta key: ' . $key . ' => ' . $value[0]); // } $categoryId = '06d34685-e759-478c-a1ab-d777639aade9'; // $categoryId = $category[0]->term_id; $data = array( 'title' => $post_title, 'url' => $post_url, 'externalId' => (string)$post_id, 'price' => $price, 'currency' => 'USD', 'categoryId' => $categoryId, 'tokenAddress' => '0x776cc86fB175A141817Ca70e9D1c64b5E5EAC133', 'tokenId' => $post_id, 'authorName' => $post_author, 'merchantId' => $merchant_id, ); $args = array( 'method' => 'POST', 'body' => json_encode($data), 'headers' => array( 'Content-Type' => 'application/json', 'Authorization' => 'Bearer ' . $api_key ), ); $response = wp_remote_post( 'http://localhost:3002/api/articles', $args ); // Check if the request was successful if (!is_wp_error($response) && wp_remote_retrieve_response_code($response) === 200) { // Post data sent successfully error_log('PayPer Article created successfully.'); } else { // Error sending data error_log('Error sending post data to Payper API to create article: ' . wp_remote_retrieve_response_message($response)); } } } } new New_Post_Notification();
Viewing 2 replies - 1 through 2 (of 2 total)