• Hi could anyone tell if we can make the Category selection to be required?

    I did not find the option now. Our app is trying to check the category for all the events.

    Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • It can be done bro.

    Add the following code snippet to require a category:

    add_filter( 'em_event_validate', 'my_em_event_validate', 10, 2 );
    function my_em_event_validate( $is_valid, $EM_Event ) {
    if( count($EM_Event->get_categories()) == 0 ){
    $is_valid = false;
    $EM_Event->add_error(__("A category must be specified.", 'events-manager') );
    }
    return $is_valid;
    }

    You can use the Code Snippets plugin to add this code snippet.

    Thread Starter kliwang

    (@kliwang)

    Thank you @joneiseman and @enkoes !

    Could you please tell where else can I add the codes if I do not use the extra plugin? I tried my theme functions.php but it does not work and has_filter(“em_event_validate”) returns false

    Adding it to the theme functions.php should work fine. If has_filter(“em_event_validate”) returns false it means you didn’t add the code snippet to your theme functions.php. The first line of the code snippet adds a function to the em_event_validate filter so has_filter(“em_event_validate”) will return true.

    Here it describes various ways to add code snippets to WordPress: https://www.wpbeginner.com/plugins/how-to-easily-add-custom-code-in-wordpress-without-breaking-your-site/

    What version of Events Manager do you have installed?

    • This reply was modified 1 month, 1 week ago by joneiseman.
Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.