I intend to let users create blog posts via the front end. I need to make sure the post title and content are each less than 100 characters.
Which hook should I hook my validation function to?
Thanks in advance.
The hook needed is wp_insert_post_data
http://codex.wordpress.org/Plugin_API/Filter_Reference/wp_insert_post_data
Try this:
Use plugin for that. It will help you needful.
Refer this: http://wordpress.org/plugins/post-title-validation/
OR
Use this code.
add_action( 'admin_notices', 'custom_error_notice' );
function custom_error_notice(){
global $current_screen, $post;
if ( $current_screen->parent_base == 'edit' ){
if((!$post->post_name && !$post_content) && $_GET['post']) {
wp_redirect(admin_url('post-new.php?empty=1'));
}
if($_GET['empty']) echo '<div class="error"><p>Warning - Please fill up all fields correctly!</p></div>';
}
}