How to Allow Different WordPress User Roles Access to the OptinMonster Plugin

Are you using WordPress and want to grant access to the OptinMonster plugin to other users? Adjusting permission settings is simple! With this guide you will be able to allow different WordPress user roles access to the OptinMonster plugin.

  1. Perform a Complete Site Backup
  2. Determine Which User Roles Have Access to OptinMonster
  3. How to Add Code to Your WordPress Site
NOTE: This guide is for advanced users who are familiar with using WordPress and PHP functions.
IMPORTANT: The code given in this guide should work as long as your site is using at least PHP 5.3+. WordPress strongly recommends using PHP 7+.

Step 1 – Perform a Complete Site Backup

There are various ways this can be done and it depends on your site and host.

However, if you have never performed a site backup before, WPBeginner compares 7 of the Best WordPress Plugins for Backing Up and Restoring your site.

After you back up your website, you can continue below.

Step 2 – Determine Which User Role Has Access to OptinMonster

By default, Administrators (and also Super-Administrators for Multi-site Installations) are the only people allowed access to edit the OptinMonster plugin. However, there are times you may want to grant access to a lower User Level.

Depending on the level you desire to grant access, you will need a different embed code. For this guide, we suggest granting access only to Editor-level user role.

Therefore the PHP code snippet you will need is the following:

Allow Editors and above:

add_filter( 'optin_monster_api_menu_cap', function( $cap ) { return 'edit_pages'; } );

Step 3 – How to Add Code to Your WordPress Site

Adding PHP Code to your site does pose some risks if the code is not added correctly. It could even potentially break your site and your access to the administrative area.

We recommend the Code Snippets plugin or add the code via FTP to your site’s functions.php file.

Congratulations, you’ve added your PHP Code Snippet to your site and the WordPress User Role you specified can now access the OptinMonster plugin!

Want to add custom forms to your campaigns? Check out how to connect OptinMonster with WPForms.


Q: What are the Code Snippets for each user role?

A: Remember, by default Super Administrators and Administrators have access to the OptinMonster plugin. If you want to grant access to lower user role levels, then you need one of the options below:

(A) Allow Editors and Above:

add_filter( 'optin_monster_api_menu_cap', function( $cap ) { return 'edit_pages'; } );

(B) Allow Authors and Above:

add_filter( 'optin_monster_api_menu_cap', function( $cap ) { return 'publish_posts'; } );

(C) Allow Contributors and Above:

add_filter( 'optin_monster_api_menu_cap', function( $cap ) { return 'edit_posts'; } );

Q: After I added my code, my website is no longer working, what happened!?

A: Check the console for any errors in the code you’ve added.

WPBeginner offers a debugging guide for WordPress here.

Also, make sure that you’ve added your code between the PHP tags. Some developers add a closing PHP tag, and if you add the code snippet after the closing PHP tag then it can break your site.

Most likely something was copied incorrectly or pasted in the wrong location. You can either (1) restore the backup you made in Step 1 or (2) you can use FTP to manually remove that code you just added.

Q: After I updated my theme, the lower user role no longer has access to OptinMonster. Why?

A: This is most likely because you manually added the code to your functions.php file and it probably got overwritten with the theme’s update. You can re-add the code again or you can use the Code Snippets plugin to have it add the code for you.