an add_action to auto-assign secondary role?
-
Would it be possible to use an “add_action” code snippet to have users automatically assigned a secondary role upon a certain action?
I’ve got an add_action that assigns a role upon adding or changing a membership level, and I’d like to be able change that to assign a secondary role upon adding or changing a membership level.
Here’s the code I’m using successfully to assign a role:
<?php add_action( 'ms_model_relationship_create_ms_relationship_before', 'ms_controller_member_assign_memberships_done_cb', 99, 4 ); function ms_controller_member_assign_memberships_done_cb( $membership_id, $user_id, $gateway_id, $move_from_id ) { $user = new WP_User( $user_id ); switch( $membership_id ){ case 280: $user->set_role( 'client' ); break; case 330: $user->set_role( 'ward_client' ); break; } }
Could this be altered to do secondary roles instead (or in addition to)?
Thanks,
Scotthttps://www.ads-software.com/plugins/wpfront-user-role-editor/
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘an add_action to auto-assign secondary role?’ is closed to new replies.