Posted: July 20, 2015 at 7:48 pm
Hi there! I’m trying to follow the instructions on this post: https://eventespresso.com/topic/admin-event-list-restrict-events-by-categorys/ but I’m guessing since “obviously this is not a real IF statement” is written in the code, that something is missing as copy pasting it and putting the right category ID and user role slug into /event-espresso-core-reg/caffeinated/admin/extend/events/Extend_Events_Admin_Page.core.php doesn’t do anything. I’d really appreciate some clarification on what to do there. Thanks so much! |
|
Hi Lauren, Please do not place any code within the core plugin files: /event-espresso-core-reg/caffeinated/admin/extend/events/Extend_Events_Admin_Page.core.php Any files within the /event-espresso-core-reg/ directory are core files and should not be edited. The code would go within your themes functions.php file or a better yet a Site Specific Plugin. The ‘obviously this is not a real IF statement’ is because in that code is basically ‘pseudo code’ to give a rough idea how you would do it. In that code the $user_role is manually set to ‘administrator’, then the next line checks if $user_role is ‘administrator’, it always will be so its not really checking anything. The user_role check isn’t really an ideal way to handle this, it should be using capabilities assigned to the role. Can you provide further details on exactly what you want to achieve please? For example is it specific users all having access to the same events within a specific category? Specific users only having access to specific events they have created themselves within a specific category etc?
|
|
Hi Tony, thanks for your reply. Essentially I want a specific user type to be able to login to the dashboard and only see events pertaining to a certain category so they can manage those but not see or manage events of other categories. For example, if we had running races but also bike races, I want one user role to see and manage only the events in the running category in the dashboard, and another for the biking category. So not necessarily the ones they have created, but for them as event admins to be restricted to see and manage only specific categories. Does that clarify? Thanks so much! |
|
Hi Lauren, As an overview what you would need to do is assign a custom capability to each of the users roles you are wanting to use. Then check for that capability within a custom function and set the term_id based on the capability. For example if you have have an ‘Event Manager – Running’ user role, you could create the capability ‘ee_view_only_running_events’ and assign that capability to the role. I recommend using the User Role Editor plugin for this. Then using a similar function to the one Dean provided previously you’ll need to check if the current user has the capability assigned to them, then set the ‘term_id’ within the where statement to match the ID for that category. For example: function by_cat( $where, $this ) { //if the current user should only view events within the running category if( current_user_can( 'ee_view_only_running_events' ) ) { $where['Term_Taxonomy.term_id'] = 7; } //if the current user should only view events within the biking cateogry if( current_user_can( 'ee_view_only_biking_events' ) ) { $where['Term_Taxonomy.term_id'] = 8; } //return $where, if the user has neither of those capabilities they can view all of the events, but $where must be returned for this to work. return $where; } add_filter('FHEE__Events_Admin_Page__get_events__where', 'by_cat', 10, 2); (Note that ID 7 and 8 will be different on your site as your categories will have their own ID) This only applies to the Event listing and not the registrations list which would require further custom development to work. If you require further help with this I would recommend contacting a developer as we can not support customisations such as these (although we can point you in the right directory such as the above). There is a list of developers familiar with Event Espresso here: https://eventespresso.com/developers/event-espresso-pros/ Does that help? |
|
Hi Tony – while thorough and helpful and despite following instructions, I still can’t get it to work. I used Site Specific plugin to put the code in, created the new capability with the user role editor, and referenced it in the code, but it didn’t even produce an error. To clarify, if the code did work, the user would be unable to click on attendees and export the Excel file? Is that right? Thanks for your time, I really appreciate it. |
|
No it simply removes all events that are not within the category from the event list. The registration view (and CSV export) are separate from event list. Here’s an example of how the above works. On my test site I have a Running Category, and a Biking Category – http://take.ms/m0nrA Note the ID for Running Category is 10. So my function looks like this – http://take.ms/xMRJb I have a ‘Running Events Test’ event that has been assigned to the Running Category – http://take.ms/hU4Lh If I log into the site to an account that has the ee_view_only_running_events capability, then go to Event Espresso -> Events. I only see the Running event – http://take.ms/DtMB2 If I log into an account that has the ee_view_only_biking_events capability and go to the same section, I only see the Biking events – http://take.ms/Q1IjV (I only have one each of those events, if more were assigned to those categories they would also display) If I log into my Admin account, I view all the events – http://take.ms/TJufv It looks like your looking for full separation of all sections within EE. Events, Registrations, transactions etc, all for individual event managers. That isn’t something EE supports within core and would require custom development from a developer using the capabilities system built into EE. |
|
Hi Tony, actually it sounds like what you described is what I am looking for. I am however using EE3 not EE4 as is in your screenshots. Is it possible the code is not working for me because it would be different in EE3? |
|
Ah apologies. Yes that does explain it. The confusion has come from your initial post including a reference to EE4 files:
From there I had assumed you were using EE4. Its turns out the code I provided above will not work with EE3, there currently is not a similar hook we can use within EE3 to do the same. It would be possible to do but would require significant customisation to Event Espresso by a developer. |
|
Ohh I must have that path because I installed EE4 but deactivated it (we were hoping to make the jump but a couple features were not available yet). Bummer! Sorry about the confusion and thanks for all your prompt help. |
|
No problem ๐ Just let us know if you have any further questions. |
|
I may be in over my head but I’m not giving up on this ๐ I’m now using phpGrid.com to create a separate access point. I’ve managed to create a custom mySQL view where the attendees are at least categorizable by event_id. Here’s the problem I am running into and hopefully I can get a tidbit of advice on it: I need to take columns from the wp_events_attendee table, and columns from the wp_events_answer table to pull attendee’s answers to questions alongside their name, address, etc. I have done this, but the problem is that the question_ids are not columns, they are just data, and they do not link correctly to the attendee. How can I alter question id values to become column headers, and get the correct answers to fill alongside the correct registration IDs under the question ID columns? Sort of like what the export to Excel function does; it creates columns for the questions. Totally understand if this is beyond the scope of EE3 support but just wanted to reach out to check. Thanks so much in advance. |
|
|
Hi Lauren, Possible? Yes, most things are. Worthwhile? Doubtful. To achieve what you are asking would entail some severe code changes to the core plugin (which we strongly advise against) as the changes you are describing would have a knock on effect throughout the plugin. If you could send data to that PHPGrid service you could possibly pull the data first, process it into the right format and send it, but EE3’s hooks to allow things like this are limited and sporadic and Tony already mentioned there’s nothing viable for this. I have a non coding option for you. Use the Roles and Permissions basic and Roles and Permissions Pro addons. Give the users the Regional Manager role and set up two Locales: running and biking(?). Set up two Venues (just with a venue title), and apply a locale to the venue. Then give each event one of the appropriate venues, and assign each manager the locale that you want them to have access to. This will then limit them to being able to access events with venues with that locale. Even if you don’t use venues, you may still be ok with this method, and just use the settings to turn off the venues from being visible to customers (or just don’t add an address). An example to clarify how this works. Create a locale called Running Now when that Regional Manager logs in he/she will see the Event you just edited/created, but no others. Does that make sense? |
Thanks so much – unfortunately the problem was more complex as I needed to cut out access to payment information. Thankfully, after immersing myself in it for hours today, I actually managed to get it to work! Thank to all of you at EE for your amazing support! |
|
|
You’re welcome and I am glad you got it working! |
The support post ‘Restricting Event Admins to manage only certain categories’ is closed to new replies.
Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.