Support

Home Forums Event Espresso Premium Show Only People Added by User when Adding New Event

Show Only People Added by User when Adding New Event

Posted: October 31, 2016 at 11:07 am


ardiaful

October 31, 2016 at 11:07 am

1- When adding a new Event I wish to show only the people added by the user adding the event in the right hand box labeled “Assign staff”. Now it shows up the full list containing all people added by different users.

2- I also need to translate word “staff” in “Assign staff”, no single word like this appears in the .po file and adding a line ‘%s staff’ => ‘Experto/s %s’ to my customization plugin does not work either.


ardiaful

November 2, 2016 at 4:22 am

Please, any update on this?


Josh

  • Support Staff

November 3, 2016 at 12:26 pm

Hi there,

Currently it doesn’t look like there’s a way to filter that list. However, you can remove the following capabilities from a user role and they will not be able to edit or delete people posts that were made by other user accounts:

ee_delete_others_peoples
ee_edit_others_peoples
ee_read_others_peoples

RE: 2-, the actual string is Assign %s


AMTA Admin

November 3, 2016 at 12:28 pm

I have a similar need and created a temporary solution to #1, but the template for that section isn’t in the /public/templates folder in the People Add-on. That means I can’t drop the file into a child theme’s root folder and have it take effect. Or I’m missing something obvious? Perhaps staff could help out with how to make that work? Having to edit instead of override a file means this change will be reversed when the People Add-on is updated (and, well, always keep things updated).
To get it working, I replaced the contents of /plugins/eea-people-addon/admin/people/templates/people_type_event_metabox_details.template.php with the code here.
Ideally, I would be able to simply save this into my theme’s root folder.


AMTA Admin

November 3, 2016 at 12:31 pm

Also: This fixes the quirk where all people are listed for every type. I don’t have a repo to pull request to for this.


Josh

  • Support Staff

November 3, 2016 at 1:05 pm

@AMTA Admin May I ask do you have a github account and if so what’s the username? We can give you access to the People add-on repository.


AMTA Admin

November 3, 2016 at 1:14 pm

It’s here: https://github.com/KinnaT


Tony

  • Support Staff

November 3, 2016 at 2:40 pm

Just to note it IS possible to load this template from within your themes directory.

Most templates use the function EEH_Template::locate_template() which checks within your themes root directory first anyway, however some templates use another function, EEH_Template::dispaly_template() which basically skips any kind of template search.

This is one of those template, but we include a filter that allows you to filter these. Something like this:

https://gist.github.com/Pebblo/4703f274437ac01b00ef093caa8646f5

Will allow you to load that template from your theme, you can use it for others just add additional checks for the template name and replace $template_path.


AMTA Admin

November 3, 2016 at 3:16 pm

Aha! Thank you! I knew I was missing something. If I’m adding additional checks, couldn’t it still read as:

$template_name = basename( $template_path );
    if( $template_name === 'people_type_event_metabox_details.template.php' || $template_name === 'something_else.template.php' ) {
// unchanged
        $custom_path = locate_template( $template_name );
// unchanged
        if( !empty($custom_path ) ) {
            $template_path = $custom_path;
        }


Tony

  • Support Staff

November 3, 2016 at 3:25 pm

Sure that will work.

You can also create an array of templates and use in_array() but really its all the same 🙂

I should also mention those filters are aimed at developers (which is why I mentioned them here), the reason we use display_template() is usually because editing the templates using it could cause problems if you don’t know what your doing. We don’t provide support for broken templates caused by using them, although we will try to point you in the right direction if we can.


ardiaful

November 4, 2016 at 5:52 am

@Tony None of these capabilities if disabled:

ee_delete_others_peoples
ee_edit_others_peoples
ee_read_others_peoples

will have effect on showing ONLY the people added by a user when creating a new event.

@AMTA Admin Your code seemed to work as it removed those people not added by user. However, if user adds new people, these won’t appear on the “Assign %s” box.


ardiaful

November 4, 2016 at 5:54 am

@AMTA Admin Plus user with Admin permission won’t see all people in the website, but just the people added by him/her.


AMTA Admin

November 4, 2016 at 12:00 pm

Are the new people assigned at least one type? The only way I can replicate this is if I don’t select any type for a person. Because the metaboxes are separated out by type, at least one type must be assigned for a person to appear in the event editor.

Bypassing the filtering for user on an admin account wasn’t a consideration I made, as I currently have 33 people across 6 types and I really hate scrolling. However, since you seem to have a use case for it, here’s a version that checks for admin capabilities
https://gist.github.com/KinnaT/0acd4cf55b671c21be1d21375d5a59be


ardiaful

November 4, 2016 at 12:23 pm

Yes, now it works like a charm. Users can only assign to an event people they have added themselves, while admin can assign any people added in the site. Nice work!

The support post ‘Show Only People Added by User when Adding New Event’ 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.

Event Espresso