Home › Forums › Calendar Products › Community Events › default category from frontend
- This topic has 14 replies, 4 voices, and was last updated 7 years ago by Ivan.
-
AuthorPosts
-
February 9, 2017 at 12:59 am #1231915IvanParticipant
Hi, so i would like users who summit from frontend to post in a default category, is there a way to do that?
February 10, 2017 at 2:21 am #1232707IvanParticipantSo, I found this thread in the forum https://theeventscalendar.com/support/forums/topic/exclude-a-category-from-community-events-form/
that seems to solve the problem I have… but I don’t understand in wich file I have to put the code
<?php add_filter( 'get_terms_defaults', 'community_events_remove_category_option', 10, 2 ); /** * Prevent specific categories from displaying as options in the Community Events Submission form * * Subsitute the IDs of the categories that you would like to exclude from the array on line #16 below */ function community_events_remove_category_option( $defaults, $taxonomies ) { if( ! in_array( 'tribe_events_cat', $taxonomies ) ) return $defaults; if( tribe_is_event_query() ) return $defaults; $defaults['exclude'] = array(4); return $defaults; }
February 10, 2017 at 3:44 pm #1233138HunterModeratorHello 🙂
My apologies for the delayed response, I was working with another support team member to come up with a working snippet which will set categories by default. Here is a link to the snippet. You will need to add it to the bottom of your theme’s functions.php file. You’ll most likely need to remove the opening php tag, which looks like this:
<?php
Please let me know how it goes and if you get stuck, try doing some general web searches on adding code to a WordPress functions.php file. Have a great weekend!
February 11, 2017 at 12:57 pm #1233426IvanParticipantthanks for the answer… but it does not totally solves my problem… because users can still uncheck the default category and choose another… is’nt there a way yo not show the category selection in the frontend form and make it autoselect only the default one?
thanks!
February 13, 2017 at 11:21 am #1233969HunterModeratorHey Ivan 🙂
Thanks for the update. It might actually be best to use CSS to “hide” the category section, then use the following snippet to assign a default category:
/* Tribe, assign a category after a Community Events submission is saved */
function tribe_ce_force_category ( $event_id ) {
wp_set_object_terms( $event_id, 'community', Tribe__Events__Main::TAXONOMY );
}
add_action( 'tribe_community_event_created', 'tribe_ce_force_category' );Let me know how it works out. Cheers!
February 13, 2017 at 2:04 pm #1234080IvanParticipantI don’t actually know what to do… I can read css, but don’t really know how to code… I tried putting the code in the themes css, in the plugin css… but is not working… can you explain me better in wich file I have to put the code?
February 14, 2017 at 11:43 am #1234756HunterModeratorSure! Try adding it to the bottom of your theme’s functions.php file. Be sure to make a backup of the functions.php file before making any changes. Let me know how it goes!
February 14, 2017 at 12:21 pm #1234773IvanParticipantdone, but is not working, I still see
February 15, 2017 at 7:01 pm #1237662HunterModeratorCould you possible share your functions.php file with me? Pastebin.com is a free tool where you can paste the code and share a link with me. Feel free to send it as a private reply.
Thanks 🙂
February 15, 2017 at 11:05 pm #1238115IvanParticipantThis reply is private.
February 16, 2017 at 3:27 pm #1239211HunterModeratorThank you for sharing the link with me. Try removing line 264, which contains the following code, then save your changes and let me know how it works:
<?php
February 17, 2017 at 4:13 am #1239796IvanParticipantThis reply is private.
February 20, 2017 at 3:47 pm #1242503HunterModeratorMy apologies, I somehow missed that line was a necessary part of your functions.php file. After further inspection, it appears you’ve added it correctly. Another route to “hiding” the category section from the CE add event form is to use something along the lines of:
jQuery( ce_event_cats ).find( "input#in-tribe_events_cat-8" ).prop( "checked", true ).hide();
Please review this article on how to implement custom jQuery. Unfortunately you’ll need to handle this customization yourself. For what is covered in the support forums, please review our What support is provided for license holders? Knowledgebase article.
Best of luck and it might also be a good idea to submit your request to our UserVoice Feature Ideas. Have a great week ahead. Cheers!
March 14, 2017 at 9:35 am #1253885Support DroidKeymasterHey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.
Thanks so much!
The Events Calendar Support Team -
AuthorPosts
- The topic ‘default category from frontend’ is closed to new replies.