Support » Plugin: Events Manager » Add Custom Fields to submission form

  • I’ve seen this link, but it didn’t actually help:
    https://wordpress.org/support/topic/adding-fields-to-event-submission-form/

    I know we can add custom fields and attributes, but those aren’t reflected on the submission form for the users. It only shows on the normal Add Event page, available on the sidebar menu.

    Any way to add these to the form itself?
    I’ve already used the Categories to add Genres (music). Now I would like to add 4 different “Categories”:

      Online Performance / Stream
      Live Show (physical location)
      Interview
      Masterclass / Webinar

    I would like users to pick one on the form and then display this on the main list where all the events are, and also on the individual event.

    How can that be achieved?

    @duisterdenhaag, I’m not a developer per se, but if you know how to do it, I am somewhat comfortable with a little bit of coding (I guess). Thanks

    The page I need help with: [log in to see the link]

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

    What you could do, is use the WordPress Categories. WordPress Categories are the ones already available in Posts and Pages. By default Events Manager only uses the custom event categories.

    To enable that, you need quite a lot of code. That is why I placed it a publicly accessible PasteBin:
    https://pastebin.com/RPAvGbxV

    Place these snippets in your theme’s functions.php file or use the easy-to-use plugin Code Snippets (not mine).

    Thread Starter Tiago

    (@iam3ple)

    Hi @duisterdenhaag

    Thank you so much for the quick reply and the code!
    So I’ve added that to the functions file. I noticed that the Events menu now shows the Blog Categories item. I’ve also added the extra placeholder to my notes (#_WPCATEGORY) so I don’t forget what it is. So far so good 🙂

    Now how can I add a dropdown menu to my submission form (events-manager/templates/forms/event-editor.php) for the users to pick one category?

    I think that’s the last step and we’re good to go 😉

    I appreciate your help!

    Thread Starter Tiago

    (@iam3ple)

    @duisterdenhaag I forgot to mention that the field has to be set to “required” on the form. I need to have that and also a way to show an error in case they don’t pick one.

    Hope you can help me with that 🙂

    I tried adding an event as an admin, added the Blog Category and it’s showing on the list so it’s working so far.

    Thread Starter Tiago

    (@iam3ple)

    @duisterdenhaag

    Sorry, I just noticed something that’s not working.
    I have this Blog Category “online-event” (slug).
    When I type it, I get an error:
    https://www.events.wavebix.website/category/online-event/

    It says “There has been a critical error on your website.”

    Do you know what that might be? And how to fix it?

    Thanks!

    You have changed the WP Query, so to say. You’ll probably need to reset your permalinks. Go to Dashboard -> Settings -> Permalinks.

    Do not change anything, just click “Save Changes” at the bottom. WP will reindex posts and pages.

    PS. That is also the solution if you suddenly get a 404-error for an existing page. 😉

    About the category dropdown…

    Guess what? WP has a built-in function for that. Check it out here:
    https://developer.wordpress.org/reference/functions/wp_dropdown_categories/

    EM works with template files that you can edit at will.
    First, copy the file:
    /wp-content/events-manager/templates/forms/event-editor.php
    To:
    /wp-content/themes/YOUR_THEME/plugins/events-manager/templates/forms/event-editor.php

    Then in the copied version you can code the WP Category Dropdown where you want it.

    EM will always first look if there is a template in that location. If not, it defaults to the original.

    Thread Starter Tiago

    (@iam3ple)

    Thanks again!

    Regarding the first issue, I went and saved the changes without making any, but I still get the same result. I tried a different browser and also on my phone, so it’s not a cache issue. I even installed the WP Super Cache plugin and deleted the cache. No luck :/ Any other tips?

    I will check the second tip for the dropdown. Thanks again 🙂

    Thread Starter Tiago

    (@iam3ple)

    @duisterdenhaag ok so I looked at that page and as an unexperienced “developer” (if I can even call myself that…), that looks like expert stuff. I wish I could understand it.

    Is there an easy way to do it with just a few lines? I see all the options there, but I have no idea what they mean… I just need the dropdown to have the categories and add the option to the database on each event and make it required.

    If that’s too much for you to explain or provide, no worries. I will have to exclude that from the website. It was just one of the main features that I wanted to include, because I want people to quickly find the type of event they are looking for 🙂

    I appreciate any help or guidance.

    Thread Starter Tiago

    (@iam3ple)

    @duisterdenhaag

    After trying some different approaches based on what some users shared on that link you sent me (some share snippets at the bottom), I’ve ended up with this and it’s showing on my submission form:
    <?php wp_dropdown_categories( 'show_option_all=Select...&hide_empty=0&required=true' ); ?>

    Form:
    https://www.events.wavebix.website/add-an-event/

    Now the thing is that even though it’s set to required, when I submit the event it doesn’t show me any error and submits the event anyway.
    Also, the selected option isn’t saved with the event. It shows as if no category has been selected…

    I don’t know if the code is 100% correct or not. Can you clarify? And can you explain what might be happening?

    Thank you 🙂

    • This reply was modified 3 years, 2 months ago by Tiago.
Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Add Custom Fields to submission form’ is closed to new replies.