Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Set a member's role in Restrict Content Pro anytime their status changes
function pw_rcp_update_role_status_change( $new_status, $user_id ) {
$role = false;
switch( $new_status ) {
case 'expired' :
case 'pending' :
case 'free' :
case 'cancelled' :
$role = 'subscriber';
case 'active' :
// if you want, set a role here
if( ! empty( $role ) ) {
$user = new WP_User( $user_id );
$user->set_role( $role );
add_action( 'rcp_set_status', 'pw_rcp_update_role_status_change', 10, 2 );

This comment has been minimized.

Copy link

@curtismchale curtismchale commented Jul 18, 2014

Shouldn't that switch statement be on the var $new_status instead of $status?


This comment has been minimized.

Copy link
Owner Author

@pippinsplugins pippinsplugins commented Jul 28, 2014

Yep, good catch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment