Projects can be created by three user types - professionals, experts, and employers. The first two can create standalone projects to share their work. But, employers can only create projects related to a job CPT.
A Jobs CPT and Projects CPT need to be a M2M relationship - but only get activated when an employer is creating a project. In other words, can I make it mandatory for a project to have a relationship with a job only if it is created by employers?
This could be solved by making the post-relationship field not mandatory for professionals and experts but mandatory for just employers.
Do users edit content in the back end or the front end?
There is no provision to modify the relationships UI in the back end where you could intervene to disable the UI to connect posts.
If they add content from the front end, you would need to use a Relationship form to connect the posts.
Access doesn't offer role-based permissions for Relationship forms in the same way it does for normal post forms, but it should be possible to either use Access shortcodes or a Conditional Block to only insert the links to the relationship form for certain roles, so that other roles do not see them.
Does that sounds like a feasible route to go down?
I used a slightly different solution to make it work. This solution is based on previous support I got from the Toolset team.
1) Create a generic multiselect field in CRED form to post projects
2) Create a view to populate that filed with job ids for jobs created by the current user
3) Insert that view in the generic field.
4) Run custom code to connect posts in m-2-m relationship.
This has worked for me in anotehr scenario and I think it will work here too but I am coming across a small problem.
Problem - the multi-select field is not populated with the information from the view BUT when I add the view as standalone to the form it shows the JSON data. The data is visible without access shortcode. So it has to do with access control but I am not sure hwo to grant access to a generic field to a user.
Here is the code that does not work --
[toolset_access role="employer" operator="allow"]
<div class="form-group job-post-form-group">
<label>[cred_i18n name='job-post-label']Select Job(s) (use command or ctrl key to select more than one job)[/cred_i18n]<span class="red-color">*</span></label>
[cred_generic_field type='multiselect' field='job-post']
{
"required":1,
"options":[ [wpv-view name="job-posts-dropdown-for-project-prompt"] ]
}
[/cred_generic_field]
</div>
[/toolset_access]
Here is the code that works -
<div class="form-group job-post-form-group">
<label>[cred_i18n name='job-post-label']Select Job(s) (use command or ctrl key to select more than one job)[/cred_i18n]<span class="red-color">*</span></label>
[cred_generic_field type='multiselect' field='job-post']
{
"required":1,
"options":[ [wpv-view name="job-posts-dropdown-for-project-prompt"] ]
}
[/cred_generic_field]
</div>
It would appear that the conditional shortcode itself isn't rendering. Though i'm not seeing any immediate issue with the shortcode itself. It appears to be correct.
Would it be possible to get admin access to the page as well as the form so that I can have a more detailed look at this one for you ?
I've enabled the private fields for your next response.
Without doing too much testing I was able to see that the issue is still replicable even on a test page and a test form that I created. hidden link
This indicates to me that there is some conflict somewhere that is preventing the shortcode from rendering as this issue doesn't occur on a fresh install.
Even on a simple post the conditional tags do not render.
If possible can you disable all the non-toolset plugins and check the test page to see if the shortcodes for the conditional start working. If not then I will need to take a copy of the site so that I can test it locally here.