[Plugin: WPL] Need some PHP help with WPL and Member Roles
-
I have this issue up on Stack Overflow but a few people suggested I post it here. I’m using the WPL plugin and need help with user roles and php which I’m no good with.
I have four custom WP user roles and four corresponding WPL roles (called memberships) with the same exact names. When someone signs up as a particular user, they are automatically added to the WPL user list, but only in the default user role (membership). I would like to have the user matched up to his/her corresponding user role automatically when signed up.
I believe the code for this lies in the WPL’s user.php page. And in this particular section of the code:
/** @input [user_id] @return wp role of user @description for getting user role (wp feature) @author Howard **/ public static function get_role($user_id = '', $superadmin_role = true) { $user_data = self::get_user($user_id); $role = $user_data->roles[0]; /** check network admin **/ if($superadmin_role and wpl_users::is_super_admin($user_id)) $role = 'superadmin'; return $role; } /** @input void @return array roles @author Howard **/ public static function get_wpl_roles() { $roles = array(); $roles['superadmin'] = 'superadmin'; $roles['admin'] = 'administrator'; $roles['editor'] = 'editor'; $roles['agent'] = 'author'; $roles['Contributor'] = 'Contributor'; $roles['subscriber'] = 'subscriber'; $roles['guest'] = 'guest'; return $roles; } /** @input {role} @return role point @author Howard **/ public static function get_role_point($role) { /** get all roles **/ $roles = self::get_wpl_roles(); /** role validation **/ if(!in_array($role, $roles)) $role = 'guest'; $roles_point = array(); $roles_point['superadmin'] = 6; $roles_point['administrator'] = 5; $roles_point['editor'] = 4; $roles_point['author'] = 3; $roles_point['Contributor'] = 2; $roles_point['subscriber'] = 1; $roles_point['guest'] = 0; return $roles_point[$role]; } /** @input {caps} and {user_id} @return boolean @description for checking if user have the capability or not @author Howard **/ public static function is($caps, $user_id) { $result = false; if(is_array($caps)) { foreach($caps as $cap) { if(self::is($cap, $user_id)) return true; } return false; } $user_data = self::get_user($user_id); if(!$user_data) return false; if($user_data->caps[$caps]) $result = true; return $result; } /** @input void @return object memberships @description for getting wpl memberships @author Morgan **/ public static function get_wpl_memberships() { $query = "SELECT * FROM <code>#__wpl_users</code> WHERE <code>id</code> < 0 ORDER BY <code>id</code> DESC"; $memberships = wpl_db::select($query); return $memberships; } /** @input void @return object membership types @description for getting membership types @author Morgan **/ public static function get_membership_types() { $query = "SELECT * FROM <code>#__wpl_user_group_types</code>"; $result = wpl_db::select($query); return $result; } /** @input void @return in membership id @description for getting unique id for new membership @author Morgan **/ public static function get_membership_id() { $query = "SELECT MIN(id) as min_id FROM <code>#__wpl_users</code>"; $result = wpl_db::select($query, 'loadResult'); /** generate new membership id **/ return ($result-1); }
The four WP roles I have (which are the exact same names in the WPL role section) is ten, trio, single, and unlimited. So, I am assuming I simply add this to the list of roles above:
$roles['ten'] = 'ten'; $roles['trio'] = 'trio'; $roles['single'] = 'single'; $roles['unlimited'] = 'unlimited';
But then there is the list below this with numbers. I don’t understand this and I’m not sure if I should add to this list as well. There is some more code beneath all that having to do with the WPL memberships which are the WPL’s version of roles, but I’m not sure what it really does.
Massive handholding in need here. I did contact WPL and already gave them all the money I had. They wanted more to settle this one last issue and I don’t have any more, and it looks like such a simple solution. Any help here?
- The topic ‘[Plugin: WPL] Need some PHP help with WPL and Member Roles’ is closed to new replies.