03/29/2016 at 2:35 pm
#370918
Keymaster
@ Kera
Ok, now I more fully understand. When you need is an action which sets an entry to unlisted when a user role switches from “Active” to “Lapsed” and visa versa. Something like this could work.
function cn_user_role( $user_id, $role, $old_roles ) {
// Check to see if the user is linked to an entry, if not, bail.
if ( ! $entry_id = get_user_meta( $user_id, 'connections_entry_id', TRUE ) ) return;
// Change the entry status based on user role.
switch ( $role ) {
case 'lapsed':
cnEntry_Action::visibility( 'unlisted', $entry_id );
break;
case 'active':
cnEntry_Action::visibility( 'public', $entry_id );
break;
}
}
add_action( 'set_user_role', 'cn_user_role', 10, 2 );
