| User | Post |
|
9:44 pm January 12, 2011
| nar
Member
| | | |
|
| posts 5 |
|
|
I am using role scoper to restrict read access to several of my pages (role names are reader and non-reader). One of my custom plugins gives a management group the ability the ability to toggle users between reader and non reader and only these groups. Using the following I am able to change the role in wordpress:
$user = new WP_User($user_id);
$user->set_role("reader");
This does not change the scoped roles/page roles assigned to the user though, how would this be acomplished?
Thanks for the help, great plugin btw!
|
|
|
9:46 pm January 12, 2011
| nar
Member
| | | |
|
| posts 5 |
|
|
I have also tailed the mysql database and not seen anything new to run, i'm at a loss on this.
|
|
|
8:53 am January 13, 2011
| Kevin
Admin
| | | |
|
| posts 2503 |
|
|
nar said:
I am using role scoper to restrict read access to several of my pages (role names are reader and non-reader). One of my custom plugins gives a management group the ability the ability to toggle users between reader and non reader and only these groups. Using the following I am able to change the role in wordpress:
$user = new WP_User($user_id);
$user->set_role("reader");
This does not change the scoped roles/page roles assigned to the user though, how would this be acomplished?
If you assign the General Roles and Page Roles directly to the group [WP reader], they will track with the user's WP role change.
|
|
|
6:08 pm January 13, 2011
| nar
Member
| | | |
|
| posts 5 |
|
|
Little bit of a long post, im walking you through what I tried earlier.
I create a page called content. When the page is created I scroll to the role scoper section at the bottom and in the reader panel I click the check for "Restrict for Page (only selected users/groups are Readers)". I then click the checkbox beside the group "reader".
I create a new user through the standard wp interface and set his role as reader, again using the standard interface. I click the user and scroll to the bottom and under scoped roles it shows that the user has reader access to my newly created page.
I navigate to my plugin and it issues the following:
$user = new WP_User($user_id); $user->set_role(nonreader");
I then login to the database and issue:
SELECT * FROM `wp_user2role2object_rs` WHERE user_id = $user_id
The role_name listed in this select is reader.
I then issue:
SELECT * FROM `wp_usermeta` WHERE user_id = 4 and meta_key = 'wp_capabilities'
The return is a:1:{s:6:"nonreader";s:1:"1″;}
I then click the user through the standard wp interface and scroll to the bottom and under scoped roles it shows that the user has access to read the page I initially created.
Can you point me where I am going wrong on this?
Thanks!
|
|
|
9:28 am January 14, 2011
| Kevin
Admin
| | | |
|
| posts 2503 |
|
|
Try executing this function call following your SQL statements:
wpp_cache_flush();
|
|
|
9:31 am January 14, 2011
| Kevin
Admin
| | | |
|
| posts 2503 |
|
|
If that doesn't solve your problem, please let me know how you are assigning the Page Roles. They should be assigned to [WP reader].
|
|
|
12:47 pm January 14, 2011
| nar
Member
| | | |
|
| posts 5 |
|
|
I am not actually running any sql from my plugin. To change the role I only do
$user = new WP_User($user_id); $user->set_role(nonreader");
The sql I showed was me manually logging in and looking at the changes to the database after my plugin issued the set_role. Would you like me to:
$user = new WP_User($user_id); $user->set_role(nonreader"); wpp_cache_flush();
Also, I am assigning the page role by using the standard wp interface. I click the page name and scroll to the bottom and at the bottom role scoper appended to the standard wp interface. There I sec the role and hit update on the page.
|
|
|
1:04 pm January 14, 2011
| Kevin
Admin
| | | |
|
| posts 2503 |
|
|
nar said:
Also, I am assigning the page role by using the standard wp interface. I click the page name and scroll to the bottom and at the bottom role scoper appended to the standard wp interface. There I sec the role and hit update on the page.
In that Editor metabox, what user or group are you selecting?
|
|
|
2:25 pm January 14, 2011
| nar
Member
| | | |
|
| posts 5 |
|
|
I am selecting the checkbox for "Restrict for Page (only selected users/groups are Readers)" then selecting the role reader.
Now when I view any of the users with the role reader it shows their scoped roles are readers of the page.
|
|
|
12:02 pm January 17, 2011
| Kevin
Admin
| | | |
|
| posts 2503 |
|
|
nar said:
I am selecting the checkbox for "Restrict for Page (only selected users/groups are Readers)" then selecting the role reader.
Don't select the user(s) checkbox in that metabox. Instead, click on the Groups tab and select "[WP Reader]".
|
|