I am using the Posts 2 Posts plugin in order to create a relation between Teachers and the Classes they teach.
- The teacher's page is a custom post type of
facultyin which teachers are added to.
facultypost has a custom meta field labeled
The classes page is a custom post type of
classin which classes are added to.
The Posts 2 Posts plugin allows me to connect the two post types,
faculty together. By doing so, I can grab a teacher's
title and display it on the
class page, and I can display a link to the
class page on the teachers page.
Outside of this... Teachers will be able to create accounts using their school email. That same email address should match the
email_address that was entered by an admin on the
I want to allow teachers to log in and only be able to edit the
class page that is associated with the
faculty page that has a custom meta field
email_address that matches their user email address.
I know this is possible, as the Role Scoper plugin allows you to do just that. The only difference is that in the Role Scoper plugin, you have to manually go into the settings, show all the pages associated with
class post type, select a user by username (not email), and add them to that page. It is cumbersome and a pain for a non-technical user to go about doing it this way.
My way would allow you to create a
faculty with a specific
email_address and link it to a
class page. Once a user logs in with a matched email address, they would see that
class page to edit.
Hopefully all this makes sense, I'm not really sure where to begin and I've spent half the day looking for answers... all which lead back to Role Scoper (which I do not want to do).
How do I allow a user to edit a single page, that is related to another page, which has a custom meta field that contains an email address that matches theirs?
Boy does that sound complicated... Much thanks and appreciation in advance for any and all help!
- User logs in
- Grab user's email address
facultypost where custom meta field of
email_addressmatches user's email
- Get that
classpost(s) that is/are linked (via Posts 2 Posts) to that
- Give user permission to edit
While the process seems pretty straight forward, I have no idea how to actually give a user permission to edit a specific custom post type page. Again, Role Scoper is capable of doing it, the next question is how.