WordPress.org

Ready to get started?Download WordPress

Forums

Events Manager
[resolved] [BUG] Cannot set a Subscriber as the author of an event or location (11 posts)

  1. Daedalon
    Member
    Posted 1 year ago #

    In Events Manager 5.3 it's not possible to set a user whose role is a Subscriber as the author of an event, neither a normal or a recurring one, or a location. The dropdown list of users who can be set as the author contains only users with the user level of Contributor or above.

    In EM settings the Subscribers can immediately publish normal and recurring events and locations so it's rather strange that they can't be set as event authors by an admin.

    The proper fix is to list all the users in this list, regardless of the role. First, admins should have the total administrative power (no one else should be even able to see that option in the UI), and second, when there's an [event_form] page, anyone can submit an event regardless of their user role and get it accepted by a moderator, making them authors of a published event. It'd be odd for an admin to not be able to eg. recreate an overlong event as a recurring one, delete the old single event and mark the recurring one as owned by the same user so they can update it as necessary.

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

  2. agelonwl
    Member
    Posted 1 year ago #

  3. Daedalon
    Member
    Posted 1 year ago #

    That worked, thanks!

    In my view this fix should be added to Events Manager after tweaking so that it only affects Events Manager's custom post types.

  4. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 1 year ago #

    I hadn't seen that fix before, but will look into that when checking this out (already reported before). I think this may be a WP problem though, because in theory any user with the right caps should be allowed to be the author.

  5. Daedalon
    Member
    Posted 1 year ago #

    Agreed, it seems like a WP "feature" that deserves an EM workaround while waiting for it to be (or not to be) fixed in WP core.

    Marking as resolved.

  6. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 1 year ago #

    I looked further into this, and WP doesn't do any checks r.e. capabilities in this case it seems. So the solution linked further up is the best one, however I've made a small tweak to it so it only applies to Event/location pages:

    //modified code from http://wordpress.org/support/topic/users-missing-from-author-dropdown-after-upgrade?replies=20
    function my_em_override_wp_dropdown_uses($output){
        global $post, $user_ID;
        if( in_array($post->post_type, array(EM_POST_TYPE_EVENT, EM_POST_TYPE_LOCATION)) ){
    		// return if this isn't the theme author override dropdown
    		if (!preg_match('/post_author_override/', $output)) return $output;
    
    		// return if we've already replaced the list (end recursion)
    		if (preg_match ('/post_author_override_replaced/', $output)) return $output;
    
    		// replacement call to wp_dropdown_users
    		$output = wp_dropdown_users(array(
    		  'echo' => 0,
    				'name' => 'post_author_override_replaced',
    				'selected' => empty($post->ID) ? $user_ID : $post->post_author,
    				'include_selected' => true
    		));
    
    		// put the original name back
    		$output = preg_replace('/post_author_override_replaced/', 'post_author_override', $output);
    	}
    	return $output;
    }
    add_filter('wp_dropdown_users', 'my_em_override_wp_dropdown_uses');
  7. Daedalon
    Member
    Posted 1 year ago #

    Thanks! This works well for locations and individual events, but should be extended support also recurring events. After including that this has my vote to be included in EM core.

    The fix would be something like this line 57 from classes/em-event-post-admin.php:

    if( $post->post_type == EM_POST_TYPE_EVENT || $post->post_type == 'event-recurring' )

  8. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 1 year ago #

    good point, although above you forgot locations:

    function my_em_override_wp_dropdown_uses($output){
        global $post, $user_ID;
        if( in_array($post->post_type, array(EM_POST_TYPE_EVENT, EM_POST_TYPE_LOCATION,'event-recurring')) ){
    		// return if this isn't the theme author override dropdown
    		if (!preg_match('/post_author_override/', $output)) return $output;
    
    		// return if we've already replaced the list (end recursion)
    		if (preg_match ('/post_author_override_replaced/', $output)) return $output;
    
    		// replacement call to wp_dropdown_users
    		$output = wp_dropdown_users(array(
    		  'echo' => 0,
    				'name' => 'post_author_override_replaced',
    				'selected' => empty($post->ID) ? $user_ID : $post->post_author,
    				'include_selected' => trues
    		));
    
    		// put the original name back
    		$output = preg_replace('/post_author_override_replaced/', 'post_author_override', $output);
    	}
    	return $output;
    }
    add_filter('wp_dropdown_users', 'my_em_override_wp_dropdown_uses');
  9. Daedalon
    Member
    Posted 1 year ago #

    Thanks, that works!

    The locations were intentionally not included in the above copy-paste as it was added just to help anyone seeing the post towards the fix.

  10. Daedalon
    Member
    Posted 1 year ago #

    Caveat found: this doesn't affect the quick edit. Any pointers on how to add support for that?

  11. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 1 year ago #

    you'll need to dig into the WP code in wp-admin folder and find out where WP does this. I'd imagine there's a similarly named hook.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.