Handling $_POST in Wordpress -
how can handle $_post in wordpress? creating custom "send" button displays in plugin's admin panel. when pressing "send" button, mails have send subscribers. how can done? how can handle custom "send" $_post button?
i have tried init, no succes:
add_action('manage_nieuwsbrief_posts_custom_column', 'nwsbrf_custom_nieuwsbrief_column', 10, 2); function nwsbrf_custom_nieuwsbrief_column($column, $post_id) { global $wpdb; $getcategories = $wpdb->get_results( $wpdb->prepare("select * wp_nwsbrf_couple inner join wp_nwsbrf_categories wp_nwsbrf_couple.category_id = wp_nwsbrf_categories.category_id , id = %d", $post_id) ); foreach ($getcategories $categorie) { switch ($column) { case 'cat': echo $categorie->category_name; break; } } switch ($column){ case 'send'; echo '<input type="submit" class="button button-secondary button-small" name="send_post" value="verzenden">'; break; } } add_action('init', 'process_send_post'); function process_send_post(){ if($_post['send_post']) { echo 'postelijk'; } }
you looking isset() function in php:
if(isset($_post['send_post'])) { // handle form } in code, try not use switch single cases, use if instead, makes code more readable , compact.
also can category of post using built-in wordpress function get_the_category($id). no need execute db query yourself
Comments
Post a Comment