AI Assistant
Notifications
Clear all

[Solved] Admin = Admin roles

5 Posts
2 Users
1 Reactions
1,745 Views
Posts: 23
Topic starter
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@mistral)
Eminent Member
Joined: 7 years ago
[#8391]

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: 5781
 Sofy
Admin
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@sofy)
Support Team
Joined: 8 years ago

Hi Mistral,

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


2 Replies
(@mistral)
Joined: 7 years ago

Eminent Member
Posts: 23
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian

Hi @sofy

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

Thanks


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

Support Team
Posts: 5781
Sofy
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian

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
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@mistral)
Eminent Member
Joined: 7 years ago

Thanks @Sofy. This is great.


Share: