Programmatically add role to users
-
Hi,
I’m developing a directory site with WPGeoDirectory, and we need an easy way to assign a custom role to users after they have bought a listing package.
(may be a good idea to create an addon for that?)So my question is how to do it programmatically. We’ll use this to get package_id:
add_action( ‘geodir_pricing_complete_package_post_updated’, function( $post_id, $package_id )And when we know what package they have bought we want to assign a role to them, probably something like this:
switch($package_id) {
case 1 || 2:
//add current user to base member role
break;
case 3 || 4:
//add current user to premium member role, etc.
break;
}So, how do we do that? I can’t find a function to do that, if I haven’t missed something of course…
Thanks a bunch,
Damir
- The topic ‘Programmatically add role to users’ is closed to new replies.