Creating and assigning groups & capabilities programmatically?
-
Hi there,
First thank you and congratulations for the great Groups plugin! I have enjoyed using it to protect pages “by hand” for groups of users through the ultra-simple UI you provide in the WP backend. But I have now to go a step further by doing things programmatically in php templates and I am afraid I need some advice.
What I was conveniently doing by hand was, for a set of manually create pages :
- define both a pair group-capability to protect the pages
- assign users to this pair for them (only) being able to read the pages
I now have to do the same in php for a set of pages created programmatically. I understand how to do the second step (assign users to group) thanks to the Groups_User_Group::create class. But I am lost in the API for achieving the first step, which I understand should result in a list of several sub-steps like:
- creating a group
- creating a capability and pairing it with the group
- protecting the pages with the group/capability pair: is it just filling up a groups-groups_read_post custom field?
I am rather a beginner than an expert in php. Do you have some code examples to help me out? Or some more precise advices on how to use the API for achieving these steps?
Many thanks in advance!
Yves.
- The topic ‘Creating and assigning groups & capabilities programmatically?’ is closed to new replies.