User_Roles_Trait.php
28 lines
| 1 | <?php |
| 2 | namespace SG_Security\Helper; |
| 3 | |
| 4 | use SG_Security\Options_Service\Options_Service; |
| 5 | /** |
| 6 | * Trait used for factory pattern in the plugin. |
| 7 | */ |
| 8 | trait User_Roles_Trait { |
| 9 | |
| 10 | /** |
| 11 | * Roles that should be forced to use 2FA. |
| 12 | * |
| 13 | * @var array |
| 14 | */ |
| 15 | public static function get_admin_user_roles() { |
| 16 | $roles = array( |
| 17 | 'editor', |
| 18 | 'administrator', |
| 19 | ); |
| 20 | |
| 21 | if ( Options_Service::is_enabled( 'sg2fa' ) ) { |
| 22 | $roles = apply_filters( 'sg_security_2fa_roles', $roles ); |
| 23 | } |
| 24 | |
| 25 | return $roles; |
| 26 | } |
| 27 | } |
| 28 |