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.
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.
You must be logged in to post a comment.
This code makes sure that post title is not empty or longer than 100 characters. You can adjust it to your needs if necessary. The code will work as follows:
post_title
andpost_status
will not be changed;your_custom_post_type
with your custom post type.The code:
There are couple of things to be aware of:
save_post
hook instead ofsave_post_{your_custom_post_type}
and remove$post_after->post_type !== 'your_custom_post_type'
condition from the code.Wish you best of luck!
Try this:
Use plugin for that. It will help you needful.
Refer this: http://wordpress.org/plugins/post-title-validation/
OR
Use this code.
The hook needed is wp_insert_post_data
http://codex.wordpress.org/Plugin_API/Filter_Reference/wp_insert_post_data