Print This page

How To Exclude Specific User Roles From The Session Expiration (Hook)

If you want to exclude the specific user roles from LoginPress session expiration. The following filter will help you to solve this problem. Simply, you need to add the following piece of code in your Child Theme’s file functions.php and update the file.

Note: In LoginPress, by default session expiration period is unlimited otherwise you have to define the session expiration time period in Session expire option in LoginPress settings tab.

function loginpress_exclude_role_session_callback() {
return array( 'administrator', 'contributor' );
add_filter( 'loginpress_exclude_role_session', 'loginpress_exclude_role_session_callback' );

Here you can return a single value or array of the roles.

That’s how you can exclude specific user roles from the session expiration in LoginPress. Check our guide on how to exclude the pages/posts from force login feature in LoginPress.