[Plugin: WPL] Adding WP User into WPL with User Role Specific Membership
-
I posted this in plugins last night and was then told to try the hacks section. I STINK AT PHP. You’ve been warned. I haven’t no freaking clue what I’m doing.
I use the WPL plugin which automatically adds new WP users into the WPL database. I am trying to figure out how to have the new users added based on their WP roles. In WPL, there are different memberships. The new users should fall into different memberships based on their WP role. Right now, everyone falls into the default membership.
public static function add_user_to_wpl($user_id) { /** first validation **/ if(wpl_users::get_wpl_user($user_id)) return true; $user_data = wpl_users::get_user($user_id); $default_data = wpl_users::get_wpl_data(-1); $forbidden_fields = array('id', 'first_name', 'last_name'); $auto_query1 = ''; $auto_query2 = ''; foreach($default_data as $key=>$value) { if(in_array($key, $forbidden_fields)) continue; $auto_query1 .= "<code>$key</code>,"; $auto_query2 .= "'$value',"; } if($user_data) { $auto_query1 .= "<code>first_name</code>,<code>last_name</code>,"; $auto_query2 .= "'".$user_data->data->meta['first_name']."','".$user_data->data->meta['last_name']."',"; } $auto_query1 = trim($auto_query1, ', '); $auto_query2 = trim($auto_query2, ', '); $query = "INSERT INTO <code>#__wpl_users</code> (<code>id</code>, ".$auto_query1.") VALUES ('".$user_id."', ".$auto_query2.")"; $result = wpl_db::q($query); /** trigger event **/ wpl_global::event_handler('user_added_to_wpl', array('id'=>$user_id)); return $result; }
This line from above (I believe) tells the new data to fall into the default membership (-1) is the ID of the default membership).
$default_data = wpl_users::get_wpl_data(-1);
This code comes from WPL’s users.php
I feel like I just need some ‘if’ statements here but I do not know much about PHP and need some massive help. I’ve been working with WPL but I ran out of money so they won’t help anymore. C’est la vie.
My previous post is here in the plugin forum. It has more info.
Any help would be appreciated. It’s my last issue to be resolved – so frustrating!
- The topic ‘[Plugin: WPL] Adding WP User into WPL with User Role Specific Membership’ is closed to new replies.