Support

Home Forums Event Espresso Premium EE4 Editor WP User show admin menu or to manage Espresso Events

EE4 Editor WP User show admin menu or to manage Espresso Events

Posted: April 5, 2014 at 9:50 pm

Viewing 3 reply threads


Jason Redcay

April 5, 2014 at 9:50 pm

Hi, I would like the editor role to have access to some pages in Event Espresso.

As per this post here I added the following to my theme’s functions.php file.

<code>add_filter (&#039;FHEE_management_capability&#039;, &#039;my_custom_menu_management_capability&#039;);
function my_custom_menu_management_capability() {
    return &#039;edit_pages&#039;;
}

add_filter (&#039;FHEE_espresso_events_capability&#039;, &#039;my_custom_espresso_events_capability&#039;);
function my_custom_espresso_events_capability($capability){
    return &#039;edit_pages&#039;;
}

add_filter (&#039;FHEE_espresso_registrations_capability&#039;, &#039;my_custom_espresso_registrations_capability&#039;);
function my_custom_espresso_registrations_capability($capability){
    return &#039;edit_pages&#039;;
}</code>

So now the Events and Registrations pages show up in the backend admin menu for editors users. Great. But when I click on them, both menu links take me to the dashboard instead of their respective pages. How to fix this? I deactivated all plugins and the issue still persists.

Thank you!


Jason Redcay

April 5, 2014 at 9:52 pm

Code doesn’t show very well. Let’s try again:

<pre class=”brush: php; gutter: true; first-line: 1; highlight: []; html-script: false”>add_filter ('FHEE_management_capability', 'my_custom_menu_management_capability');
function my_custom_menu_management_capability() {
return 'edit_pages';
}

add_filter ('FHEE_espresso_events_capability', 'my_custom_espresso_events_capability');
function my_custom_espresso_events_capability($capability){
return 'edit_pages';
}

add_filter ('FHEE_espresso_registrations_capability', 'my_custom_espresso_registrations_capability');
function my_custom_espresso_registrations_capability($capability){
return 'edit_pages';
}


Dean

April 7, 2014 at 2:55 am

Hi,

Sorry about the code brush, it’s not very good. Pastebin is a great alternative.

OK, well Josh’s code will indeed load the pages on the Editors admin dashboard. However the problem is that there is a function that checks capability (_check_user_access() in EE_Admin_Page_Loader.core.php) that is not filterable or pluggable and it loosk solely for manage_options.

This leaves you with two choices:

1) Edit the core file to look for edit_pages as well. Not really recommended as you will have to do it every time the plugin is updated.

2) Give the editors manage_options rights. Yes this does open up a lot of other menus, but what you could do is another function to remove those menus – https://codex.wordpress.org/Function_Reference/remove_menu_page

function remove_menus(){
  
  if(current_user_can( 'editor' ) ) {

  remove_menu_page( 'index.php' );                  //Dashboard
  remove_menu_page( 'edit.php' );                   //Posts
  remove_menu_page( 'upload.php' );                 //Media
  remove_menu_page( 'edit.php?post_type=page' );    //Pages
  remove_menu_page( 'edit-comments.php' );          //Comments
  remove_menu_page( 'themes.php' );                 //Appearance
  remove_menu_page( 'plugins.php' );                //Plugins
  remove_menu_page( 'users.php' );                  //Users
  remove_menu_page( 'tools.php' );                  //Tools
  remove_menu_page( 'options-general.php' );        //Settings

	}  
}
add_action( 'admin_menu', 'remove_menus' );

I’ll add a feature request for a filter to be added, as this would obviously be the better option.


Jason Redcay

April 9, 2014 at 1:33 pm

Thanks, Dean that helps! I went with option 2. And since I am already using Adminimize (another wp plugin) I can just use that to hide menus for editors. The combination of Josh’s code and adding manage_options cap for editors is what worked.

Thanks again!

Viewing 3 reply threads

The support post ‘EE4 Editor WP User show admin menu or to manage Espresso Events’ 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