before_delete_post – problems
-
Hey guys,
i made myself a plugin. It inserts/edits/deletes WP-Posts into another database. But i want to have an error message if the DB-Connection fails. If i dont “stop” inserting/editing/deleting if the connection is not established, it is going to get really annyoing.
This is my code (just getting started coding with WP ?? )
——————————————–
function project_insertDB(){
//insert post
}function project_deleteDB(){
//delete post
}function project_editDB()<7
//edit post
}add_action(‘publish_project’, ‘project_insertDB’);
add_action(‘before_delete_post’, ‘project_deleteDB’);
add_action(‘edit_post’, ‘project_editDB’);
——————————————————–I thought about a simple
if(!$connection){
exit(“No database connection”)
}inside each function with different messages. The problem is, it fires the “project_insertDB” even if i am just editing and it doesnt prevent WP from f.e. deleting an already existing post if you want to put it into the trash. It shows the error message, but didnt stop putting it into the trash. Is there a way to, lets say, stop WP from doing someting? And to net let fire “project_insertDB” if i am just editing a post?
I am not a native speaker, so i hope that makes sense ;P
Thanks in advance,
Lui
- The topic ‘before_delete_post – problems’ is closed to new replies.