如何在 wordpress 中处理 $_POST?我正在创建一个自定义“发送”按钮,该按钮显示在我的插件的管理面板中。当按下“发送”按钮时,邮件必须发送给订阅者。但这怎么能做到呢?如何处理自定义“发送”$_POST 按钮?
我试图用init来做,但没有成功:
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 * FROM wp_nwsbrf_couple INNER JOIN wp_nwsbrf_categories WHERE wp_nwsbrf_couple.category_id = wp_nwsbrf_categories.category_id AND ID = %d", $post_id) );
foreach ($getcategories as $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';
}
}