• Resolved zwene

    (@zwene)


    Hi,

    great plugin. But I have one problem that let me return to The Events Calendar all time:

    If I create an event in Events Manager and set the accessibility e. g. with UAM or PressPermit only to some user groups or user roles, they are visible in the Calendar Grid all time. And this means it’s unusable if you don’t want to publish them to guests or some user groups. πŸ™

    I search all over the net, here in the support forum and in the Events Calendar support section and I haven’t found something about this problem. πŸ™

    Have someone an idea how to get Events Manager to consider the user access in the calendar grid

    Greetings,
    zwene

    http://wordpress.org/plugins/events-manager/

Viewing 15 replies - 1 through 15 (of 45 total)
  • Plugin Support angelo_nwl

    (@angelo_nwl)

    “The Events Calendar” I think this one is a different plugin or did you mean WP FullCalendar instead?

    Thread Starter zwene

    (@zwene)

    No, I mean the one from Modern Tribe. I don’t know why, but it’s the only calendar plugin I found that respects user accessibility in it’s grid view.

    But for me it’s to overburden, I love Event Managers in union with the above-named WP FullCalendars easy adaptability.

    Thread Starter zwene

    (@zwene)

    I tested a little bit with custom conditional placeholders, but I don’t get it that the title and the link doesn’t shown if the user habe no rights to read the event if logged in:

    add_action('em_event_output_condition', 'my_em_user_access', 1, 4);
    function my_em_user_access($replacement, $condition, $match, $EM_Event){
        	$events_page_id = get_option ( 'dbem_events_page' );
    	$events_page = get_post($events_page_id);
    	$user_can = current_user_can('read', $events_page);
    	if( !$user_can ) {
    			$replacement = '';
    		}
    	else {
    			$replacement = '#_EVENTNAME';
    	}
    	return $replacement;
    }

    Any ideas?

    Plugin Support angelo_nwl

    (@angelo_nwl)

    Thread Starter zwene

    (@zwene)

    The shown code is based on in. πŸ˜‰

    The code you’ve used looks like it’s checking against the capabilities for viewing the main events page, not individual events whereas it sounds like you want to limit access to certain events, not the whole calendar.

    Thanks

    Thread Starter zwene

    (@zwene)

    Ah, thank you. After a little testing I can say that

    $events_page_id !0 $EM_Event->ID

    But it doesn’t change something:

    • event is restricted to one of two user groups
    • restriction for showing in the fullcalendar (both the included and wp fullcalendar) $user_can = current_user_can(‘read’, $EM_Event->ID);

    Result:

    • guests can’t read it -> event entry isn’t showing -> correct
    • users from user group who should read the event -> event is showing -> correct
    • users from user group who shouldn’t read the event -> event is showing -> not correct πŸ™

    Here my acual code:

    add_action('em_event_output_condition', 'my_em_user_access', 1, 4);
    function my_em_user_access($replacement, $condition, $match, $EM_Event){
        	$events_page_id = get_option ( 'dbem_events_page' );
    	$user_can = current_user_can('read', $EM_Event->ID);
    	if( !$user_can ) {
    			$replacement = '(gesperrt)' . ' ' . $EM_Event->ID;
    		}
    	else {
    			$replacement = '#_EVENTNAME' . ' ' . $EM_Event->ID;
    	}
    	return $replacement;
    }

    Sounds like you’re using BuddyPress?

    If so, when you say “users from user group”, do you mean users who are part of the group the event belongs to? Or any user at all who just happens to be in a group?

    Thread Starter zwene

    (@zwene)

    No, I simply want to restrict access of some events to members of diffent user groups. I test it with UAM, Groups and PressPermit – no chance. πŸ™

    If you are user of a user group or with special capatilities, you get the following mystery:

    1. User with read access to the event

    • can see event name and permalink in fullcalendar grid
    • can enter the event page by clicking on the event link in the fullcalendar grid

    2. User without read access to the event

    • can see event title and permalink in fullcalendar grid too
    • can not enter the event page by clicking on the event link in the fullcalendar grid and get’s an error page instead

    Isn’t it crazy? You can’t enter/read a page, but you can read the event title with permalink to it in the fullcalendar grid. πŸ™

    Can it be a bug in wp fullcalendar? If I only test it with simple WordPress Posts I get the same result.

    I’ll ask Marcus to confirm, but I’m pretty sure this is the way it’s supposed to work.

    There was a similar a question a few months ago. As far as I remember, the issue is that by default WordPress only checks user capabilities for the page the user is currently on. It doesn’t “look ahead” at the content of links in a page.

    I imagine it would be possible to write some code that does that, but I think it would be an in-depth task.

    Thread Starter zwene

    (@zwene)

    Thank you. πŸ™‚

    Thread Starter zwene

    (@zwene)

    Sooooo – I have an update for you:

    After installing a clean WP with pure WP FullCalendarall works well with post type = post. All user groups get only the events they have access to.

    And then I installed a clean Events Manager, changed in WP FullCalendar post type to event, create an event for one user group – and nothing worked well anymore. The problem is back.

    Oh, and the events are visible to all in the event list with the same problems.

    Strange …

    Plugin Author Marcus (aka @msykes)

    (@netweblogic)

    I think I can explain:

    We don’t use WP_Query for querying posts. That’d be why a plugin like UAM wouldn’t filter out these events from the list. That’d also be why posts work as expected because EM isn’t hooking in.

    We do this for various reasons including speed and better MultiSite support, although I do intend one day to have a ‘WP_Query’ mode alternative.

    Currently, the only way to hide these events would be to make them private and control who has read_private_events. Or alternatively events belonging BuddyPress groups that are hidden/private would create the same effects.

    Thread Starter zwene

    (@zwene)

    Ah, thanks, that make it more clear for me. Now I understand why the only working way at the moments are user capatilities.

    Because of your explanation I look a bit around and found

    http://wordpress.org/plugins/wp-access-areas/

    which uses virtual user groups by using conditional capatilities. In this way the em user condition works fine:

    add_action('em_event_output_condition', 'my_em_user_access', 1, 4);
    function my_em_user_access($replacement, $condition, $match, $EM_Event){
            global $current_user;
            get_currentuserinfo();
    	$user_can2 = current_user_can('read', $EM_Event->ID);
    	$user_can = current_user_can('post_view_cap', $EM_Event->ID);
    	if( current_user_can('userlabel_1_schueler', $EM_Event->ID) || current_user_can('userlabel_2_lehrer', $EM_Event->ID) ) {
    			$replacement = '#_EVENTNAME';
    		}
    	else {
    			$replacement = '(gesperrt)';
    	}
    	return $replacement;
    }

    Excellent. Thanks for the update and code post, that’ll probably help someone else.

Viewing 15 replies - 1 through 15 (of 45 total)
  • The topic ‘Visibility of events in calendar grid’ is closed to new replies.