1. Home
  2. Knowledge Base
  3. OptimizeMember
  4. Forcing a specific EOT demotion rule [OptimizeMember]

Forcing a specific EOT demotion rule [OptimizeMember]


Many of OptimizeMember’s Hooks/Filters make it possible to customize things in more advanced ways, which might not be available yet through the OptimizeMember UI panel in your Dashboard.

If you want to force OptimizeMember’s Auto-EOT System to demote paying customers back down to a specific Role, instead of the free “subscriber” Role that OptimizeMember uses by default, you could use this hack to accomplish that.

Hack Instructions

Create this directory and file:

/wp-content/mu-plugins/opm-hacks.php

(these are MUST USE plugins, see: http://codex.wordpress.org/Must_Use_Plugins)

Add this code the file and modify accordingly:

<span class="pun" style="tab-size: 2; word-wrap: normal; color: rgb(131, 148, 150);"><?</span><span class="pln" style="tab-size: 2; word-wrap: normal; color: rgb(189, 54, 19);">php</span>
<span class="pln" style="tab-size: 2; word-wrap: normal; color: rgb(189, 54, 19);"> add_filter</span><span class="pun" style="tab-size: 2; word-wrap: normal; color: rgb(131, 148, 150);">(</span><span class="str" style="tab-size: 2; word-wrap: normal; color: rgb(38, 145, 134);">"ws_plugin__optimizemember_force_demotion_role"</span><span class="pun" style="tab-size: 2; word-wrap: normal; color: rgb(131, 148, 150);">,</span><span class="pln" style="tab-size: 2; word-wrap: normal; color: rgb(189, 54, 19);"> </span><span class="str" style="tab-size: 2; word-wrap: normal; color: rgb(38, 145, 134);">"my_demotion_role"</span><span class="pun" style="tab-size: 2; word-wrap: normal; color: rgb(131, 148, 150);">);</span>
<span class="pln" style="tab-size: 2; word-wrap: normal; color: rgb(189, 54, 19);"> </span><span class="kwd" style="tab-size: 2; word-wrap: normal; color: rgb(133, 153, 0); font-weight: bold;">function</span><span class="pln" style="tab-size: 2; word-wrap: normal; color: rgb(189, 54, 19);"> my_demotion_role</span><span class="pun" style="tab-size: 2; word-wrap: normal; color: rgb(131, 148, 150);">(</span><span class="pln" style="tab-size: 2; word-wrap: normal; color: rgb(189, 54, 19);">$default </span><span class="pun" style="tab-size: 2; word-wrap: normal; color: rgb(131, 148, 150);">=</span><span class="pln" style="tab-size: 2; word-wrap: normal; color: rgb(189, 54, 19);"> </span><span class="str" style="tab-size: 2; word-wrap: normal; color: rgb(38, 145, 134);">"subscriber"</span><span class="pun" style="tab-size: 2; word-wrap: normal; color: rgb(131, 148, 150);">)</span>
<span class="pln" style="tab-size: 2; word-wrap: normal; color: rgb(189, 54, 19);"> </span><span class="pun" style="tab-size: 2; word-wrap: normal; color: rgb(131, 148, 150);">{</span>
<span class="pln" style="tab-size: 2; word-wrap: normal; color: rgb(189, 54, 19);"> </span><span class="kwd" style="tab-size: 2; word-wrap: normal; color: rgb(133, 153, 0); font-weight: bold;">return</span><span class="pln" style="tab-size: 2; word-wrap: normal; color: rgb(189, 54, 19);"> </span><span class="com" style="tab-size: 2; word-wrap: normal; color: rgb(189, 189, 189); font-style: italic;">/* I say it is... */</span><span class="pln" style="tab-size: 2; word-wrap: normal; color: rgb(189, 54, 19);"> </span><span class="str" style="tab-size: 2; word-wrap: normal; color: rgb(38, 145, 134);">"my_custom_role"</span><span class="pun" style="tab-size: 2; word-wrap: normal; color: rgb(131, 148, 150);">;</span>
<span class="pln" style="tab-size: 2; word-wrap: normal; color: rgb(189, 54, 19);"> </span><span class="pun" style="tab-size: 2; word-wrap: normal; color: rgb(131, 148, 150);">}</span>
<span class="pun" style="tab-size: 2; word-wrap: normal; color: rgb(131, 148, 150);">?></span>

Here’s another example – in this example a level 2 or 3 users will be demoted to level 1, and level 1 would be demoted to level 0 (subscriber) level:

<? php add_filter ( 'ws_plugin__optimize_force_demotion_role' ,  'my_demotion_role' );  function  my_demotion_role ( $role =  'subscriber' )  {  if  ( current_user_is ( 'optimizemember_level3' )  ||  current_user_is ( 'optimizemember_level2' ))  $role =  'optimizemember_level1' ;  return  $role ;  }

Was this article helpful?

Related Articles

Need Support?
Can't find the answer you're looking for? Don't worry we're here to help!
Contact Support