I’ve little drawback how implement deleting information from database utilizing row actions. I’ve my customized record which incorporates information from database desk.
perform column_name( $merchandise ) {
$delete_nonce = wp_create_nonce();
$title = '<robust>' . $merchandise['article_name'] . '</robust>';
$actions = [
'edit' => sprintf('<a href="?page=%s&id=%s">Edit</a>', 'edytuj-artykul', $item['article_id']),
'delete' => sprintf('<a href="?page=%s&action=%s&article_id=%s&_wpnonce=%s">Delete</a>', esc_attr( $_REQUEST['page'] ), 'delete', absint($merchandise['article_id']), $delete_nonce)
];
return $title. $this->row_actions( $actions );
}
perform delete_article($merchandise){
$article_id = $merchandise['article_id'];
world $wpdb;
$desk = 'wp_copywriter_articles';
$wpdb->question("DELETE FROM $table WHERE article_id = %d", $article_id);
}
In the identical file I added
add_action( 'admin_action_delete', 'delete_article' );
After I click on Delete motion, nothing happend. I bought hyperlink
http://localhost/wordpress/wp-admin/admin.php?web page=Artykuly&motion=delete&article_id=26&_wpnonce=60a01b82d7
however report isn’t deleted from database.
For testing, I added a selected ID variety of article to the delete_article methodology within the SQL question however nonetheless not works, so this methodology isn’t utilized by WP, once I click on delete button.
Somebody can provide me any tip what am I doing unsuitable, as a result of I spent on this few few hours 🙂
Finest Regards,
Bartek