How to Disable OptinMonster for Logged in Users

Want to avoid annoying active users with your campaigns? It’s easy with OptinMonster’s WordPress plugin! This guide will show you how to automatically hide your OptinMonster campaigns from visitors who are logged in to your WordPress website.

Important: Targeting users following this guide works only with websites that utilize’s Content Management System. It may be possible to target based on the logged-in status on other platforms using the display rules in the campaign Builder or using Google Tag Manager to control where the embed code is loaded on your site.

  1. OptinMonster Plugin
  2. Configure the Output Settings

Step 1 – OptinMonster Plugin

Log into the WordPress Admin and navigate to the OptinMonster > Campaigns screen. Here you’ll see a list of campaigns that have been synced to your site from OptinMonster. If you don’t yet see any campaigns available, or if the campaign you want to configure isn’t shown, select the Refresh Campaigns button to sync the latest campaigns.

Next, select the Edit Output Settings link below the title of the specific optin you wish to configure:

Edit Output Settings

Step 2 – Configure the Output Settings

This will open the Output Settings screen where we’ll configure who can see the campaign. Look to the Who should see this optin? setting, which has the following options available:

  • Show campaign to all visitors and users
  • Show campaign to only visitors (not logged-in)
  • Show campaign to only users (logged-in)

After specifying your Output Settings, save the changes and visit your site to see the new setting in effect.

Visitor Selection

That’s it, save the settings and the campaign embed code will now be added to your site only if the user’s logged-in status meets the settings defined in the Output Settings!

If you want to disable OptinMonster for a specific user role in your membership site, then simply paste the following code in your theme’s functions.php file.

function om_docs_hide_optin_for_user_roles( $campaigns ) {

	// Do nothing if no user is logged in.
	if ( ! is_user_logged_in() ) {
		return $campaigns;

	// Change these as necessary.
	$roles_to_check = array( 'administrator', 'subscriber' );

	// Get the current user.
	$user = wp_get_current_user();

	if ( ! empty( $user->roles ) && is_array( $user->roles ) ) {
		$has_role = array_intersect( $roles_to_check, $user->roles );
		if ( ! empty( $has_role ) ) {
			// Remove all campaigns for these particular roles.
			$campaigns = array();

	// Return the potentially modified campaigns.
	return $campaigns;
add_filter( 'optin_monster_api_final_output', 'om_docs_hide_optin_for_user_roles' );

Interested in other ways you can utilize the OptinMonster WordPress plugin? See how the OptinMonster Display Rules and WordPress plugin work together!