Using code to change user's role
-
Hi,
As I needed to have a customisable register form for BBPress, I changed the registration to the customisable fields I needed and altered the database. This works fine.
However now when a new user registers and logs in, they cannot view the profile page as a “You do not have sufficient permissions to access this page.”
When I look in the back end as an admin the user is automatically given the role of “subscriber”. If changed to “Forum Participant” the user is allowed to view the profile page, however I want the role to be set automatically, rather than the admin doing it.
So I have got to the point where in the registration process I have this code so far to fix this:
//Where $u is the newly registered user who has been added to the database
$u->remove_role( ‘subscriber’ );
$u->add_role( ” );
The problem is I don’t know the parameter in the add_role function for Forum Participants (or any other way to do this).
If anyone could tell me this it would be greatly appreciated!
Thanks in advance
- You must be logged in to reply to this topic.