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!

In this article, you will learn how to automatically disable OptinMonster for logged-in users within WordPress.

Before You Start

Here are some things to know before you begin:

  • 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.

Disable OptinMonster for Users

This feature is great to use if you want to target a specific audience within WordPress.  Do you want to show your campaigns to guests and not bother your logged-in users?

When you are ready to hide certain campaigns from logged-in users, follow these steps:

  1. First, navigate to the OptinMonster Plugin in your WordPress dashboard.
  2. Then, click Edit Output Settings beneath the campaign you wish to configure.
    Edit Output Settings
  3. Next, click on the drop down list below Who should see this campaign?
    Visitor Selection
  4. Choose from these three options.
    • Show campaign to all visitors and users
    • Show campaign to only visitors (not logged-in)
    • Show campaign to only users (logged-in)
  5. When you are finished click Save 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' );