M_Roles_joinedlevel

The Membership 2 M Roles joinedlevel function.

Description

M_Roles_joinedlevel( $tolevel_id, $user_id ); 

Parameters (2)

0. $tolevel_id
The tolevel id.
1. $user_id
The user id.

Usage

  1. if ( !function_exists( 'M_Roles_joinedlevel' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'membership-2/app_old/membershipincludes/addons/integrated.wproles.php'; 
  3.  
  4. // The tolevel id. 
  5. $tolevel_id = null; 
  6.  
  7. // The user id. 
  8. $user_id = null; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = M_Roles_joinedlevel($tolevel_id, $user_id); 
  12.  

Defined (1)

The function is defined in the following location(s).

/app_old/membershipincludes/addons/integrated.wproles.php  
  1. function M_Roles_joinedlevel( $tolevel_id, $user_id ) { 
  2.  
  3. // Set up the level and find out if it has a joining ping 
  4. $level = new M_Level( $tolevel_id ); 
  5. $member = new M_Membership( $user_id ); 
  6.  
  7. $wprole = $level->get_meta( 'associated_wp_role' ); 
  8. if(!empty($wprole)) { 
  9. if(method_exists($member, 'has_cap') && !$member->has_cap('activate_plugins')) { 
  10. $member->set_role( $wprole ); 
  11.  
  12.