wpf_admin_override

#Overview

By default WP Fusion excludes administrators (users with the manage_options capability) from any access restrictions on content.

This can be disabled by unchecking the box for Exclude Administrators on the General settings tab in the WP Fusion settings.

If you need to customize this behavior, for example to target different user roles, or to exclude specific user IDs, you can use the wpf_admin_override filter.

To use the code examples below, add them to your active theme’s functions.php file.

#Parameters

  • $override: Whether or not to activate the admin override.

#Examples

#Check a different capability

The example below will treat all users with the edit_others_posts capability as admins for the purposes of WP Fusion.

function custom_admin_override( $override ) {
	
	if ( current_user_can( 'edit_others_posts' ) ) {
		$override = true;
	}
	return $override;
}

add_filter( 'wpf_admin_override', 'custom_admin_override' );

#Check a different role

The example below will treat all Editors as admins for the purposes of WP Fusion.

function custom_admin_override( $override ) {
	
	if ( current_user_can( 'editor' ) ) {
		$override = true;
	}
	return $override;
}

add_filter( 'wpf_admin_override', 'custom_admin_override' );

Was this helpful?