Tips and Tricks HQ Support Portal › Forums › WP eMember › eMember and WordPress default user roles not working
Tagged: eMember, registration, roles, Users
- This topic has 11 replies, 2 voices, and was last updated 12 years ago by essexreporter.
-
AuthorPosts
-
November 9, 2012 at 5:41 pm #7868essexreporterMember
Have a problem that I thought others might have and have searched the forums for an answer, but no luck.
I recently integrated my eMember members with WordPress, so they are all WordPress users now. I have set all defaults on membership levels to “Subscriber” and have also set the default new user setting in WordPress to “Subscriber.”
When new users register with eMember, they are made WordPress users with Admin status — not good! I have to manually change the roles of these users — trying to catch them early enough before they find out they can edit my pages!
Here’s what I’ve checked:
“eMember_misc_functions.php” file and searched for “wp_create_user” but could not find anything like that.
Any fixes?
November 10, 2012 at 4:09 am #51225adminKeymasterWhat version of eMember are you using?
Have you tried reloading a fresh copy of the plugin first?
https://support.tipsandtricks-hq.com/forums/topic/re-install-or-load-a-fresh-build-of-the-plugins
November 11, 2012 at 6:30 pm #51226essexreporterMemberHey,
So just reloaded a fresh copy of the eMember plugin thinking that would def work since I didn’t try it first….but no luck! I just tried to register and was automatically made an admin again…
Any other ideas?
November 11, 2012 at 6:35 pm #51227essexreporterMemberHere’s the current code:
function eMember_wp_create_user($user_name,$password,$email)
{
if (eMember_is_multisite_install()){//MS install
global $blog_id;
if($wp_user_id = email_exists($email)){// if user exists then just add him to current blog.
add_existing_user_to_blog( array( ‘user_id’ => $wp_user_id, ‘role’ => ‘subscriber’ ) );
return $wp_user_id;
}
$wp_user_id = wpmu_create_user($user_name, $password, $email);
eMember_log_debug(“Creating WP User using Multi site API. User ID: “.$wp_user_id.” Blog ID: “.$blog_id,true);
$role = ‘subscriber’;//TODO – add user as a subscriber first. The subsequent update user role function to update the role to the correct one
if (add_user_to_blog($blog_id, $wp_user_id, $role)){//Add user to the current blog
eMember_log_debug(“WP MS user successfully added to blog ID: “.$blog_id,true);
}else{
eMember_log_debug(“WP MS user addition to blog failed!”,false);
}
return $wp_user_id;
}
else{//Single site install
$wp_user_id = wp_create_user($user_name, $password, $email);
eMember_log_debug(“Creating WP User using single site API. User ID: “.$wp_user_id,true);
return $wp_user_id;
}
Seems correct, right?
November 12, 2012 at 4:45 am #51228adminKeymasterYeah that code is definitely correct. I sent you an email to get access to the site so I can investigate this further.
November 13, 2012 at 4:21 am #51229adminKeymasterHi, I just created an eMember user from the dashboard to test and the role of this user was correctly set to subscriber. All of your other users also seem to have the “subscriber” role (I checked it in your WP Users list). So it seems to be working fine. Am I missing something?
November 13, 2012 at 1:49 pm #51230essexreporterMemberThe other users in my list have a subscriber role because I changed them to Subscribers.
I’m not sure what’s going on. I was happy to see your test user ended up a subscriber, but the trouble comes when I tested it (Went onto the site as a “Guest,” clicked on our “Subscribe Now” button on the site, actually paid $5 through Paypal and eStore and followed all registration links, made a new user) I ended up an Admin.
I don’t understand it either.
November 13, 2012 at 1:51 pm #51231essexreporterMemberFrom the dashboard, I can create any user with the correct info, but for new users who use eStore to subscribe themselves, problems arise. I’m not sure if it’s eStore, the registration link or a bug in WordPress…
November 14, 2012 at 2:36 am #51232adminKeymasterOkay that means the eStore button that you created has reference to a Wrong membership level (this is my guess at the moment). Please post a link to this “Subscribe Now” button that you used so I can check the details of that product.
November 14, 2012 at 1:36 pm #51233essexreporterMemberSure, here’s the link: [http://www.essexreporter.com/admin/join-us-4]
When guests click our Subscribe Now button, it leads them to this page. Behind the scenes, is [wp_eStore_subscribe_fancy id=1].
Thanks for checking it out!
November 15, 2012 at 8:36 am #51234adminKeymasterLooks like my suspicion came true. You have specified “1” in the “Reference Text” field of this eStore product. You don’t have any membership level with ID 1. Edit this product and correct this value.
November 16, 2012 at 4:02 pm #51235essexreporterMemberWow, thanks so much- I never would have thought to check there!
So far, so good. I think this problem is resolved!
Thanks again- have a great holiday
-
AuthorPosts
- You must be logged in to reply to this topic.