• Resolved cyberlp23

    (@cyberlp23)


    Hello,

    I’m trying to trigger an action if, when a user tries to publish a post, no category is selected:
    – It could either be just an alert message (and the post is still published);
    – Or actually alter message + preventing the post from being published.

    Searching on this forum, I’ve found the code:

    jQuery('#submitdiv').on('click','#publish',function(e){
                var $checked = jQuery('#category-all li input:checked');
                if ( $checked.length <= 0 ) { //Checks if cat is selected
                alert("Please Select atleast one category");
                return false;
                }else{ //Else continue
                    return true;
                }
                });

    But I have no idea where to put it.

    Thanks!

Viewing 2 replies - 16 through 17 (of 17 total)
  • How to get that checked category id in a php function

    Moderator bcworkz

    (@bcworkz)

    The checked category term IDs are in the $_POST['post_category'] array.

    FYI, feel free to start a new topic in these forums, your question actually has very little to do with this thread. Most tagged on questions fail to be on topic, so we encourage new topics here ??

Viewing 2 replies - 16 through 17 (of 17 total)
  • The topic ‘Prevent posting when no category is selected’ is closed to new replies.