Tips and Tricks HQ Support Portal › Forums › WP eStore Forum › WP eStore General Questions › Integration with Simple Press Forum? › Reply To: Integration with Simple Press Forum?
Amin,
I checked into this further, and came up with some pseudo-code that should make this fairly simple for you to integrate…If this isn’t what you were looking for for code, let me know.
The code is obviously vague & generic, but you should see how it fits into your store plugin…
1. Display Dropdown
global $wp_roles;
$roles = array_keys($wp_roles->role_names)
if($roles)
{
foreach($roles as $index=>$role)
{
echo "<option>$role</option>";
}
}
2. On Save – Set per product option
$storeoption['prodnum']['role'] = $_POST['role_option'];
3. On User Create
$user = new WP_User($id);
$user->add_role($storeoption['prodnum']['role']);
Things to consider:
if a user exists (for another product perhaps?), then the highest role should be used.
If a product role changes (not a good idea, I know), then there should be an option to either change all users, or to set the new role from this point forward. (Or just pick one, and we can all live with it )
I hope that’s a bit more informative of what I’m looking for, and how you could implement it in your plugin.
If you intend to implement this, please let me know. Otherwise I’ll make plans to make due with a single membership forum.
Thanks
Matt