Support

Home Forums Event Espresso Premium EE4 Permissions/ WP Capabilities

EE4 Permissions/ WP Capabilities

Posted: October 29, 2014 at 6:57 pm


Randi

October 29, 2014 at 6:57 pm

WP: 4.0
Espresso: 4.3.3.p
PHP 5.4.32
I have several users that need full Admin access to Espresso to manage events, etc.

I’ve inserted the following code into my functions.php file:

function my_grant_permissions() { return ‘publish_posts’; }
add_filter (‘FHEE_management_capability’, ‘my_grant_permissions’);
add_filter (‘FHEE_espresso_events_capability’, ‘my_grant_permissions’);
add_filter (‘FHEE_espresso_registrations_capability’, ‘my_grant_permissions’);
add_filter (‘FHEE_espresso_transactions_capability’, ‘my_grant_permissions’);
add_filter (‘FHEE_espresso_registration_form_capability’, ‘my_grant_permissions’);

With this set, I have full access as administrator. Also var_dumped the arg to the filter callback and verified that it is returning ‘publish_posts’.

When an user with Editor role logs in they can see the Espresso menu on the Admin sidebar, but when they click on anything, e.g.; Events, it just repaints the screen and does not go into the Events Listing. The Event Espresso menu is also missing from the toolbar. From the dashboard, if I click on the Events link in the At a Glance Meta Box, I also get nothing. Just wondering if the code above is correct or if anyone has encountered anything like this this. I have 10 users with adminstrator access to work around this. Not good. Also, no plugins to speak of, just Yoast SEO.

Thanks in advance


Lorenzo Orlando Caum

  • Support Staff

October 29, 2014 at 7:18 pm

Hi,

Could you comment out your coding and try this example?

https://eventespresso.com/topic/ee4-paired-down-admin/#post-118343


Lorenzo


Randi

October 29, 2014 at 8:36 pm

I commented out the code and added the following from the example:

add_filter (‘FHEE_management_capability’, ‘my_custom_menu_management_capability’);
function my_custom_menu_management_capability() {
return ‘edit_posts’;
}

Still got the same result. Full EE menu in sidebar, no Event Espresso nav in toolbar, links go nowhere.

After this, I added this after the above code snippet to see what is return (using the default priority, then again at 99) and it $cap had a value of ‘edit_posts’ each time it was called.
add_filter (‘FHEE_management_capability’, function($cap) { var_dump($cap); return $cap; });

I tried pasting the link to the Events listing (http://domain/wp-admin/admin.php?page=espresso_events) and it redirected to /wp-admin (even when I was on a posts admin page).

Tried flushing the rewrite rules, just for the hell of it. No luck.

Thanks


Randi

October 29, 2014 at 8:37 pm

Forgot to mention… works as expected when logged in with an account with administrator role assigned.


Randi

October 29, 2014 at 8:40 pm

Seems as if I’m having the same issue as:
https://eventespresso.com/topic/how-to-make-ee4-options-available-for-non-adminstrators/


Dean

October 30, 2014 at 2:48 am

Hi,

This is my response to the other thread you linked to:

I tested the above code (though I changed the capability to “read”) and saw no issues – screenshot http://take.ms/RWFr4

Do you have any other plugins that affect user roles/capabilities active?

I also tested with edit_page and it was fine.


Dean

October 30, 2014 at 2:48 am

Hi,

This is my response to the other thread you linked to:

I tested the above code (though I changed the capability to “read”) and saw no issues – screenshot http://take.ms/RWFr4

Do you have any other plugins that affect user roles/capabilities active?

I also tested with edit_page and it was fine.


Randi

October 30, 2014 at 7:30 am

Thanks Dean,

I just disabled all plugins (except Espresso) and installed a Minimalist theme (Blank Slate), logged out and logged back in (using an account with editor role). I get exactly the same thing.

This is what I was using:

add_filter (‘FHEE_management_capability’, ‘my_custom_menu_management_capability’);
function my_custom_menu_management_capability() {
return ‘edit_posts’;
}

I also returned ‘edit_page’ & ‘read’, with the same result. Also tried a fresh install of WP 4.0 installing only Event Espresso & the Blank Slate theme (with code snippet above) to no avail.

Here is a screenshot:
http://www.synergemarketing.com/espresso.jpg

Interesting that I get a different menu from your screenshot. I would also expect to see the Event Espresso menu on the WP Toolbar, which is absent from both screenshots. Clicking on Events, Registrations or Transactions go to /wp-admin (after a delay), which returns me to the dashboard screen regardless of what page I am on in the admin.

Any insight would be appreciated.


Josh

  • Support Staff

October 30, 2014 at 10:33 am

Hi Randi,

Did you grant the “manage_options” capability to the editor role?


Randi

October 30, 2014 at 11:09 am

Hi Josh,

I missed the manage_options part in the forum post. Applying it to the users capabilities did the trick!

One aside, the Event Espresso WP Toolbar menu still is not display. Is there another WP capability required for that?

Thanks!


Lorenzo Orlando Caum

  • Support Staff

October 30, 2014 at 1:42 pm

Hi Randi,

I ran a search on the coding that handles that and it needs admin privileges:

	public function espresso_toolbar_items( $admin_bar ) {

		// if in full M-Mode, or its an AJAX request, or user is NOT an admin
		if ( EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance || defined( 'DOING_AJAX' ) || ! current_user_can( 'administrator' )) {
			return;
		}


Lorenzo

The support post ‘EE4 Permissions/ WP Capabilities’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso