• I have two wordpress pages. One for “Formal tours” and one for “Informal Tours”. (In this case “Events” can be considered “Tours” and “Venues” as “Locations”).

    My plan is to:
    Have 4 user groups
    Administrator – full permission
    Staff – Can only add formal tours/events
    Member – Can only add informal tours/events
    Member Moderator – Can moderate informal tours/events.

    My strategy #1
    – Duplicate the “Events” tab and functionality from the admin panel so that there are 2 of them
    – Duplicate the permission set under Settings -> Event Organiser for both formal and informal.
    – Create an empty copy of the tables for the new tab
    The main downside to this that I see is: I will eventually have a calendar that display both formal and informal tours, and so I’de have to modify the calendar shortcode as well if I wanted to use this option.

    My strategy #2
    – To create 2 Event categories: Formal Tours and Informal Tours. And find a way to separate permissions in which category people can add their events.
    – To have sub-categories in those categories that go into more details, for example “Local Tours” etc.

    So right now I don’t have a clear method of doing this, but I was hoping I could get some new ideas or ways I could implement what I’m asking for. I’m also looking into using external plugins to manage these permissions.

    Thanks a lot.

    https://www.ads-software.com/extend/plugins/event-organiser/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter tridentspk

    (@tridentspk)

    This is a 2 step problem.

    The first portion is differentiating between formal and informal tours and I’m still trying to figure that out, but I started of with categories:
    https://www.ads-software.com/support/topic/getting-list-of-venue-ids-which-have-events-that-match-certain-event-category?replies=1

    The second portion is the permissions side of things. I think the best way is if someone is authorised to add formal tours for instance, it’ll have “Formal tours” already checkboxed as the category and hidden so when its submitted it will automatically be in the right place.

    So this thread I guess is more focused on getting the permissions right.

    Plugin Author Stephen Harris

    (@stephenharris)

    Certainly #2 is the way to go here. #1 is fraught with difficulties and would involve a lot of work.

    For 1, the following (untested!) should ensure that the event is saved only with the appropriate category (you’ll need to fill in the details):

    add_action( 'save_post', 'tridentspk_set_event_category' );
        function tridentspk_set_event_category( $post_id ) {
    
            if( !current_user_can( 'edit_post', $post_id ) )
                return;
    
            if( 'event' != get_post_type( $post_id ) )
                return;
    
            //Get the user ID
            $user_id = get_current_user_id();
    
            if( user is to create events with cat x ){
                 $slug = 'formal-tours';
            }else{
                 $slug = 'informal-tours';
            }
    
            $term = get_term_by( 'slug', $slug, 'event-category' );
            wp_set_post_terms( $post_id, $term, 'event-category' );
        }
    Plugin Author Stephen Harris

    (@stephenharris)

    Certainly #2 is the way to go here. #1 is fraught with difficulties and would involve a lot of work.

    For 1, the following (untested!) should ensure that the event is saved only with the appropriate category (you’ll need to fill in the details):

    add_action( 'save_post', 'tridentspk_set_event_category' );
        function tridentspk_set_event_category( $post_id ) {
    
            if( !current_user_can( 'edit_post', $post_id ) )
                return;
    
            if( 'event' != get_post_type( $post_id ) )
                return;
    
            //Get the user ID
            $user_id = get_current_user_id();
    
            if( user is to create events with cat x ){
                 $slug = 'formal-tours';
            }else{
                 $slug = 'informal-tours';
            }
    
            $term = get_term_by( 'slug', $slug, 'event-category' );
            wp_set_post_terms( $post_id, $term, 'event-category' );
        }
    Plugin Author Stephen Harris

    (@stephenharris)

    You could also have a third option to check if the user is an admin and in which case the script doesn’t over-ride the event category.

    Not sure what capabilities the ‘Member moderator’ would require, but you should look up the map_meta_cap filter (see codex / a tutorial I wrote on this.)

    The basic idea is you have a ‘meta capability’ such as ‘edit_post’ (can the user edit this post). WordPress maps these into ‘primitive’ capabilities such ‘edit_posts‘ (can the user edit posts), ‘edit_other_posts’ (can they edit posts by other users) etc?

    How the meta capability is mapped to a primitive one will depend on the user and their permissions. E.g. if the user is the post author they just need the capability to edit posts. If they are not, they’ll also need the permission to edit other people posts (admins typically can). There are also checks if the post is already published.

    You can add your own, to see which category the post lies in. If it lies in ‘informal’ and the current user is a ‘member moderator’ then you would allow them to edit it. If its ‘formal’, you would not.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘What is the best way to create an independent copy of events and permissions?’ is closed to new replies.