Tagged: moldavian girls
- This topic has 10 replies, 2 voices, and was last updated 10 years, 3 months ago by Bartosz.
-
AuthorPosts
-
4 September 2014 at 07:19 #4881jmcbadeParticipant
I would suggest another category for this forum: “How To”, as some of these requests are Not bugs, but may not qualify as a feature request either, in that they may already be possible somehow.
I want to have some calendars of events “public facing” and some “private facing” – using a password I would imagine.
Is there currently a way to do this with Event Maker?
My guess, is that I would have a page that had no password, and one that did. I guess I would have a category for public and one for private? It would be even better to be able to have a list of categories that were public and another that were private.
How would I solve this requirement?
Thank you
5 September 2014 at 21:18 #4921BartoszKeymasterInteresting question.
I was thinking about that for a while and I believe it can be done without any plugin code changes.
1. You need 2 pages for events calendar – public and private (with password) – in this second case you’ll probably have to manually output the calendar shortcode wrapped with post_password_required() function. just adjust your theme here if needed. I’d probably create 2 page templates for this, to be able to use it in query later
2. Now you need to distinguish between public and private events. A couple of options here – but I suggest creating 2 categories (public, private) or, better, 2 tags (public, private) – especially if you don’t tag your events.
3. Assign all your events to public or private category (or tag)
4. You should now have 2 event calendars on 2 separate page templates, first available publicly, second only for users that enter the correct password. But the content of those calendars is still the same, so…
5. You have to filter those depending on the page displayed. Again, at least 2 options:
a) use the em_get_full_calendar_events_args filter available in just released 1.2.0. to modify the posts query arguments. thise arguments are exactly the same as in get_posts() function, so you’ll definitely find a way to do this. you need to run this filter on the both calendar pages (using is_post_template(), is_page() or any other conditional tag). in public page you use this filter to include public category events only, and on private page you include private category events subsequently
b) use the pre_get_posts filter to alter events query on this 2 calendar pages. the logic is the same as in a) – it only differs in the way of execution.
VoilĂ :)
There are more things to do, if you need to protect the private events – but you asked about the calendar, so I covered this.
6 September 2014 at 01:25 #4930jmcbadeParticipantThank you for the thoughts on this and your time to reply.
I’m learning more about WP and coding everyday, and I will try to execute your suggestions.
Meanwhile, for the “Features List”, unless you have some philosophical reason to oppose this, could you add some parameters to your short code in a future release? ex: [em_full_calendar ‘cat=1’] or [em_full_calendar ‘tag=1’] something like that? Then we just password the page. This would need to be something the Events widget uses also.
As I think about it, even though your pages idea would work, I believe the Widget will still expose everything right?
Thanks
6 September 2014 at 14:54 #4932jmcbadeParticipantMeanwhile, I am lost after this point:
5. You have to filter those depending on the page displayed. Again, at least 2 options:
I also think these tips do not address the widget and how to modify it.
Again, sorry if I am not as advanced in programing PHP/WP as you. I am really trying. If you can offer any more help, I would greatly appreciate it.
Thanks
6 September 2014 at 22:27 #4935BartoszKeymasterOk, to make it clear: do you mean the Full Calendar or the Events Calendar widget? Those are completly 2 different elements.
I thought you were asking about the Full Calendar, the one you create separete page for.
7 September 2014 at 00:07 #4937jmcbadeParticipantI am originally talking about the full calendar yes.
In my addressing the whole picture ie: having public and private events (one is public facing and one is for our staff), so, wanting some events to be private only, I would not want to have my full calendar hide the private events, only to have them exposed when I use the widget somewhere.
See my point?
I really appreciate your helping me with the ways to do this. I guess I am more than a beginner, but barely and intermediate coder for PHP/WP :)
I just am not sure in which template file(s) and their loops that I would need to filter the the events. I have in the past, used WP_query to create and object before a loop on the home page to filter from only one or more categories and it works :P
Now if I knew which file(s) for events templates to do something like this as you have suggested, I guess?, something like that I might be able to pull this off for Calendar pages and widgets.
Wouldn’t it be better? (you tell me), if the [em-full-calendar] accepted parameters for the $args variable? ex: [em-full-calendar ‘category=2,7’]
Wouldn’t it be better if the widget could accept a tick box for guest and registered people and a field for categories or tags etc.
I bet a brilliant and experienced guy like you could write that kind of code faster than you could reply to my email :P, but I would still like to know more of how to do this as well.
Honestly, I really am trying to learn and figure this out.
Again, I very much appreciate your time and effort on this.
Thanks
8 September 2014 at 10:30 #4944BartoszKeymasterOk, so you need a complete solution for this, not only the calendars. Of course I can’t tell you step by step how to do this, but the key method is to use the pre_get_posts filter. We can do this because Events Maker is purely a WP post type.
So:
function df_filter_events_query($query) { // apply this everywhere, except admin, on every event query if (!is_admin() && $query->get('post_type') === 'event') { // you must have a condition to recognize for which user hide private events, for example if user is not logged in if (!is_user_logged_in()) { $tax_query = array(); // build new tax query to exclude private events $tax_query = array( 'taxonomy' => 'event-category', // assuming you created private and public categories 'terms' => 'private', 'field' => 'slug', 'operator' => 'NOT IN' // this is the key ); // merge our query excluding private events (filed under "private" event-category), with any tax query if (!empty($tax_query)) { $query->tax_query->queries[] = $tax_query; $query->query_vars['tax_query'] = $query->tax_query->queries; } } } } add_action('pre_get_posts', 'df_filter_events_query');
This might handle all that, globally. You need is to adjust that to your needs, escpecially the condition under which the filter is fired.
8 September 2014 at 10:42 #4946jmcbadeParticipantThanks. I will see if I can make this work. I have created other “pre” filters before successfully.
Sorry if this is a dumb question, but will this apply to the widget also somehow?
Much appreciated.
8 September 2014 at 10:46 #4948BartoszKeymasterThis will apply to every event query, including widgets, calendars, events archive pages, single pages, etc.
And that’s the trick.
8 September 2014 at 10:58 #4949jmcbadeParticipantThanks, I’ll be giving it a go and maybe this will help someone else to :)
Any thought to making the short codes take parameters?
What do you think of that idea?Just curious.
8 September 2014 at 11:01 #4950BartoszKeymasterYes, we have added that in our to-do list.
-
AuthorPosts
- You must be logged in to reply to this topic.
How to Get Support
After you register and login to the site, you may post all plugin support questions in the Support Forum.
If you need to provide private info, please create a ticket and then reply to it using Set as private reply option.
Sign Up
Please login or sign up for a free account.Sign Up Now