Two Issues I need to solve

This topic contains 1 reply, has 2 voices, and was last updated by  Stephen Harris 10 years, 10 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #6245

    There are two issues I need to solve from my previous thread

    I got most of 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
    #6247

    1. The code in question is in js/edit-event-controller.js (actually the minifed copy is used). The HTML mark-up is just a drop-down and the ‘add new’ rows (which are by default hidden)- everything else (the autocomplete, the select/add buttons,) is javascript.

    I think the easiest way is to automatically hide the ‘select venue’ row, and show the ‘add new section’ and hide the ‘cancel’ button. Try adding the following javascript after everything else.

      $('.eo-venue-combobox-select').hide();
      $('.eo-add-new-venue').show();
      $('.eo-add-new-venue-cancel').hide();
    

    (You’ll want to put this at the end, but still inside jQuery(document).ready(function($) { .... }))

    2. I think you’ll want to use the map_meta_cap filter – specifically when checking if someone has permission to edit_post (note the lack of an ‘s’). Usually WordPress allows the user to edit a post if:

    • They are the post author and can edit_posts and edit_published_posts (if its published)
    • They can edit_posts and edit_published_posts (if its published) and edit_others_posts

    (This is all in includes/event-organiser-cpt.php).

    The idea is that no-one has the capability to ‘edit_post’ – its a meta capability. Instead WordPress maps that capability to a collection of required ‘primitive’ capabilities (e.g. edit_posts, edit_others_posts etc) which are assigned to roles – depending on context.

    In your case you’re trying to treat a primitive capability: edit_others_events has meta one. As far as WordPress is concerned you either can edit other peoples posts or you cannot – there is no half-way houses. However, you can implement this in a slightly hacky way:

    The idea is that if you allow moderators the ability to edit_others_events. When you come to map the meta capability edit_post – if the current user is a moderator and not the author you:

    • make no change if they can edit the event (i.e. its of their province)
    • otherwise add an additional primitive capability requirement which they don’t have: e.g. ‘edit_other_provinces_events’. (Its a made up capability, so the user won’t have it – so you effectively deny them the ability to edit the post in question).

    I wrote this post at WP Tuts last year which might be better at explaining how WordPress handles capabilities: http://wp.tutsplus.com/tutorials/creative-coding/capabilities-and-nonces/

    Stephen Harris
Viewing 2 posts - 1 through 2 (of 2 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.