Viewing 9 replies - 1 through 9 (of 9 total)
  • Hi Peter,

    I’m not sure what you mean when you say it makes the event a concept. Could you rephrase? Thanks.

    Thread Starter ptrv

    (@ptrv)

    Sorry, it’s the WP translation. I mean Draft. All events published after adding the code to my functions.php get the Draft status. Whether I select a category right away, or after the error message when I didn’t.

    Plugin Support angelo_nwl

    (@angelo_nwl)

    can I know if you want the snippet to work on the frontend only or also in the backend?

    Thread Starter ptrv

    (@ptrv)

    Only on the backend.

    That’s standard WordPress behavior.

    If at least one element (title, content, etc.) has been filled in the post will be saved as a draft even if it’s not published immediately because of an error.

    Thread Starter ptrv

    (@ptrv)

    Yes, but the purpose of the code/error message is to make sure a certain field (category in this case) is filled. The error message is “category is required.” So you would expect that when you correct this error – select a category – the event will be published normally. Now the error message should be “you forgot to select a category and after that make sure that you change the status of the event from Draft to Published”.

    So maybe the code is not really suitable for using in the backend?

    Thanks, Peter

    I can see your point, but as I say it follows standard WordPress behavior so you’d need to create a filter for that part of the WordPress code if you want to change it.

    Thread Starter ptrv

    (@ptrv)

    I solved it by using the require-post-category plugin. In the require-post-category.php file changed:
    if($post_type=='post'){
    to
    if( ($post_type=='event' || $post_type=='event-recurring') ){
    and
    if($('#taxonomy-category input:checked').length==0){
    to
    if($('#taxonomy-event-categories input:checked').length==0) {
    or to
    if( ($('#taxonomy-event-categories input:checked').length==0) || ($('#taxonomy-event-categories input:checked').length>2) ){
    if you want only one category to be selected (like me).

    Maybe this is some help to someone.

    Thanks for your answers, Peter

    Thanks for the post Peter. I was looking for a solution just like this!

    Regards,
    John

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Make category a mandatory field’ is closed to new replies.