Hi
I am using a plugin, TDO Mini Forms, that enables users to add new posts online using forms. In some forms, I want to change the role of users.
For example, I want to change the role from subscriber to contributor.
In the form, it is possible to add php code. Here is the code.
<?php
$user = wp_get_current_user();
$user->set_role('subscriber');
?>
It does change the role.
Of course, if I post this on Role Scoper, it is because I am using Role Scoper.
I restricted some pages to contributors thanks to Role Scoper.
So when the role was changed from subscriber to contributor, I expected the pages available to contributors would automatically available to subscribers changed to contributors.
Actually, I noticed I had to go to the profile of the user, click once on Update User, and then, the user would have access to contributor pages.
I added one line in my code.
<?php
$user = wp_get_current_user();
$user->set_role('subscriber');
wp_user_update($user_id);
?>
Thanks to this line, it worked automatically, but I don't understand why, it creates a new empty user (it creates just a new ID).
Do you have any idea on what I should put instead of wp_user_update($user_id) ?
It would help me a lot if you have some.
Thank you very much for your support.