Notifications
Clear all

wpForo 1.x.x [Solved] Admin = Admin roles

5 Posts
2 Users
1 Reactions
1,098 Views
Posts: 23
Topic starter
(@mistral)
Eminent Member
Joined: 6 years ago

Hi

We are wanting to give forum admins access to parts of the Wordpress admin but not all of it. Right now the requirement to establish if they are admin are quite high. (activate_plugins, install_plugins, create_sites)

Could I request that you add a filter on the function wpforo_current_user_is, which would allow us to determine if they are admin ourselves.

Or is there another method to solve this?

Thanks

Mistral

4 Replies
Sofy
Posts: 4772
 Sofy
Admin
(@sofy)
Support Team
Joined: 7 years ago

Hi Mistral,

I'm going to ask this question to wpForo developers. I'll update this topic asap. 

2 Replies
(@mistral)
Joined: 6 years ago

Eminent Member
Posts: 23

Hi @sofy

Please could I get an update on this thread...

Thanks

Sofy
 Sofy
Admin
(@sofy)
Joined: 7 years ago

Support Team
Posts: 4772

Hi @mistral,

The hook will be added in the next version release.

Please follow the steps below to get it to work in your case: 

In the functions.php file located in wp-content/plugins/wpforo/wpf-includes/ folder, find the wpforo_current_user_is() function and replace with the following one:

function wpforo_current_user_is( $role ) {
$role = strtolower( $role );

$filter_result = apply_filters('wpforo_current_user_is', NULL, $role);
if( !is_null($filter_result) ) return (bool) $filter_result;

switch ( $role ) {
case 'admin':
if ( current_user_can( 'activate_plugins' ) ) {
return true;
}
if ( current_user_can( 'install_plugins' ) ) {
return true;
}
if ( current_user_can( 'create_sites' ) ) {
return true;
}
break;
case 'moderator':
if ( WPF()->perm->usergroup_can( 'aum' ) ) {
return true;
}
if ( current_user_can( 'moderate_comments' ) ) {
return true;
}
if ( current_user_can( 'edit_published_posts' ) ) {
return true;
}
if ( current_user_can( 'manage_categories' ) ) {
return true;
}
break;
}

return false;
}

As I've already mentioned, the changes will be included in the next version, so you can update the plugin without any worries, the changes will not be lost. 

Posts: 23
Topic starter
(@mistral)
Eminent Member
Joined: 6 years ago

Thanks @Sofy. This is great.