How would I implement these event add/edit permissions? (Screenshots included)

WordPress Event Management, Calendars & Registration Forums General Question How would I implement these event add/edit permissions? (Screenshots included)

This topic contains 6 replies, has 2 voices, and was last updated by  weston 10 years, 10 months ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #6236

    Hi this is me, borrowing the account I created for my client to ask an important questions for event organiser. To avoid duplicate posting, I will direct you to the question here:
    http://wordpress.org/support/topic/how-would-i-implement-these-event-addedit-permissions-screenshots-included?replies=1

    Thanks a lot

    Oh and this account can’t download the event organiser pro plugin for some reason. Must be a permissions thing.

    weston
    #6238

    Hi,

    I’ve just posted a response, but in future you’d be better of just using this forums – since these get more attention :).

    Regarding the download – this is because I’ve migrated the purchaser to the new account – but there seems there is a bug with the e-commerice platform which means its still not accessible. I’ll be looking into this. The (new) license key is handled seperately and should work without any problems. In the mean time uou already have a copy of the plug-in so you can move that to your client’s site where updates can be handled in the normal way.

    All the best,

    Stephen Harris
    #6241

    I have been editing the core plugin files for all of my modifications instead of placing them in a separate file, because I find it more convenient that way. So continuing to do so is not really an issue for me.

    I tried to add this code to my functions.php file in my themes folder and it didn’t work!

    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(current_user_can('member_bc')){
             $slug = 'formal-tours';
        }else{
             $slug = 'informal-tours';
        }
    
        $term = get_term_by( 'slug', $slug, 'event-category' );
        wp_set_post_terms( $post_id, $term, 'event-category' );
    }
    

    It wouldn’t even checkmark the event category without the permissions check. Hmmm :/ And also I tried to add an event without any category checkmarked and it didn’t assign it either.

    Also I tried this code to remove the event categories and it doesn’t work!
    remove_meta_box( ‘categorydiv’, ‘event’, ‘normal’ );

    I’ve tried all combinations :/

    Also where is the core plugin file responsible for adding the event categories metabox? And which file(s) manage the user roles permissions like manage_venues?

    weston
    #6242

    I solved the problem with removing the metabox. It was

    remove_meta_box( ‘event-categorydiv’, ‘event’, ‘side’ );

    But the other problem still remains. How to automatically checkmark the appropriate fields

    weston
    #6243

    I got the features done by using the Members Plugin, Role Scoper Plugin, and Adminize

    These all allowed me to restrict the category based on their user role. But it did not hide some of the categories on the list, so I had to hide it completely. And if I want someone who can add both formal and informal events, then I would have no choice but to display all categories so they can checkmark one or the other option.

    So right now, I need to figure out a way to:

    1.) Get the + sign or add a new venue selection to appear automatically. i’ve figured out a way to do that, but the problem is that it doesn’t save the venue information if i don’t click the + sign first. How do I get around that? Because I don’t want to display a list of existing venues

    2.) I know i’ll be able to allow provincial moderators the ability to add formal or informal events for their province. But I think my client also wants me to allow those moderators the ability to edit other people’s events, but only those that are in British Columbia or whichever provincial moderating position is assigned. How would I go about doing this when it displays the list of “all events”?

    Thanks.

    weston
    #6246

    Hi Weston,

    I have been editing the core plugin files for all of my modifications instead of placing them in a separate file, because I find it more convenient that way.

    Just keep in mind that if you update the plug-in you’re changes will be lost…

    Here’s a corrected code for forcing selection of an event category:

    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( current_user_can( 'member_bc' ) ){
            $slug = 'stand-up';
        }else{
            $slug = 'mycat';
        }
    
        $term = get_term_by( 'slug', $slug, 'event-category' );
        wp_set_post_terms( $post_id, array( $term->term_id ), 'event-category' );
    }
    

    Please note that it doesn’t pre-select the category terms – it only sets the terms when the event is saved (but you’re hiding the metabox anyway…)

    Stephen Harris
    #6248

    Thanks for the help. Sorry for the multiple posts. I’m gonna stick to this thread until my project is done.

    Heres an update on what I’ve done so far:

    1.) Instead of hiding the venue list, what I did was, I edited event-organiser-ajax.php to display a list of venues only in B.C, A.B etc.

    2.) Instead of using Role Scoper, I decided to disable it and try the code you gave me instead, and I was able to successfully select two categories (one is the parent category and the other is the child category), using this code:

    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( current_user_can( 'member_bc' ) ){
        $slug = 'formal-tours';
    $slug2 = 'tours-canada';
    }else{
        $slug = 'mycat';
    }
    
    
    $term = get_term_by( 'slug', $slug, 'event-category' );
    $term2 = get_term_by( 'slug', $slug2, 'event-category' );
    
    wp_set_post_terms( $post_id, array( $term->term_id, $term2->term_id ), 'event-category' );
    
    }
    

    Not only that, but your code also automatically checkmarked the appropriate categories, and if I unchecked them and changed them upon submission, it would still save the event in the categories from the code above. So thats good

    3.) As for the meta_cap_filters for only displaying a list of events for the B.C province or whatever for a moderator. I’ll look into that, but I’m also considering an alternative so I’ll let you know how that goes.

    4.) If the individual (in this case a provincial moderator) can create either formal or informal events, I’m going to make a default setting for them of “formal” and then if they choose to checkmark informal instead, then I’ll do a check in event-organiser-edit.php for their role and somehow retrieve the checkmark category they choose and override the final category selection from the code you gave me.

    5.) If I decide to do number 4, it would be nice if they would be only allowed to select one subcategory: “either formal or informal” but not both. So like for example if they checkmark formal tours and then checkmark informal tours, it would uncheck the formal one.

    So basically right now I made this post to keep you updated on what it is I’m working on, and later on if I get stuck on a solution I will make a new post about it.

    Thanks.

    weston
Viewing 7 posts - 1 through 7 (of 7 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.