Scenario:
Parent post - Project Prompt
Child Post - Group
Relationship - M2M
Intermediate Post - Workspace
A group can have multiple members and these members are assigned to the group by adding their email addresses to a multiple value custom field. This list of emails is then stored in a custom field on the workspace post.
A workspace is meant to be a place where members get together and work on a group project. One step in the group project is the evaluation of every teammate.
I am using generic fields to create an evaluation rubric and then storing that data as a JSON in the workspace custom field. The JSON/ array will look like this -
[Evaluater1 Email] [evaluatee1 email] [rubric-element-1] [rating]
[Evaluater1 Email] [evaluatee1 email] [rubric-element-2] [rating]
[Evaluater1 Email] [evaluatee1 email] [rubric-element-3] [rating]
[Evaluater1 Email] [evaluatee2 email] [rubric-element-1] [rating]
[Evaluater1 Email] [evaluatee2 email] [rubric-element-2] [rating]
[Evaluater1 Email] [evaluatee2 email] [rubric-element-3] [rating]
.....
[Evaluater4 Email] [evaluatee3 email] [rubric-element-1] [rating]
[Evaluater4 Email] [evaluatee3 email] [rubric-element-2] [rating]
[Evaluater4 Email] [evaluatee3 email] [rubric-element-3] [rating]
To store the data as above, I need to show the list of evaluatees in the edit workspace form so that
1. Evaluator can select 1 evalutee at a time and then rate using the rubric
2. The list of evaluatees keep on decreasing with each evaluation.... something like 2/3 complete .... 3/3 complete.
I am struggling to find a way to show the user list as a dropdown on the edit workspace form. I tried to use a view but could not find a way to filter
1. Users based on emails listed in the custom field on workspace post
2. Filter user-profile posts (proxy for users ... only one per user) where the author email is one of the emails listed in the custom field on workspace post
I don't want to create an evaluation post type just to capture a one-time evaluation and would rather have all the data stored in the workpace post as a JSON. Another reason to not do this is - I would need to create a relationship between workspace and evaluation but as workspace is an intermediary post so it seems like that cannot happen.
Hi,
> A group can have multiple members and these members are assigned to the group by adding their email addresses to a multiple value custom field. This list of emails is then stored in a custom field on the workspace post.
- I see a big challenge in this approach. The original source of member information is the group post where the emails addresses are stored. If you're copying those emails to a custom field in workspace post too, you'll have to keep special care to keep those emails in-sync across the group post and the workspace post, because if a member is later removed from the group, his/her email will need to be removed from the group's post. But the related workspace post will still have that member email in its custom field.
To avoid this, I wouldn't store the email addresses again in the workspace post and would call them from the original source, i.e. custom field from the related group post, whenever needed.
> 1. Users based on emails listed in the custom field on workspace post
- If you know the ID of the current workspace post, you can get the emails from the custom field using the Type Fields API:
https://toolset.com/documentation/customizing-sites-using-php/functions/#email
You'll add a generic field and populate its options using a custom shortcode, that will return the options based on the emails coming from the custom field.
> 2. Filter user-profile posts (proxy for users ... only one per user) where the author email is one of the emails listed in the custom field on workspace post
- Again, this will need a custom shortcode, that can first get the user IDs from the found emails. Once you have the IDs, you can use the 'get_posts' function to return only those user-profile posts, where the post author is one of the found IDs:
https://developer.wordpress.org/reference/functions/get_posts/
https://developer.wordpress.org/reference/classes/wp_query/#author-parameters
regards,
Waqar
My issue is resolved now. Thank you!