Tell us what you are trying to do? I need to update post_title and relationships automatically. A supervisor is assigned to a facility and department. When a team member is assigned to that supervisor, the team member should automatically form a relationship with the facility and department of the assigned supervisor. If anyone has some sample code to look at I can probably figure it out from there. I am using the beta with the new relationships.
Is there any documentation that you are following? If you could point me towards where this is covered, I would appreciate it.
Is there a similar example that we can see? that's what I'm hoping you can provide.
What is the link to your site? Local site under development
We need to know much more about your setup.
Please explain to us the setup showing a structure of your posts and how they relate.
What you would like to happen when which post is updated, and where (backend or frontend).
Basically, if you want to have relationships or other things set up "automatically" upon certain actions this is the approach to take:
1. Determine when and where this should happen and then use either a Toolset or WordPress Hook to fire your code at that moment
2. Determine what should be updated (where from is data, where does it go) so you can choose the right WordPress API to manipulate your post or user.
3. Craft a custom code that is hooked at the right moment and passes the right data to the right posts or users.
We can help with this by providing examples but need to know exactly how your structure looks.
Maybe you have a working site where you can show us the desired workflow, even if just hypothetically?
I am sorry if I was not clearer in my initial request. I am developing an HR system that will be used by multiple facilities each with multiple departments. Here are the basic business rules and what I have set up so far:
1. Each Facility (CPT) has multiple Departments (CPT) [many to many]
2. Supervisors (user role with custom field group) work for one department within one facility
3. Team Members (CPT) report to a single supervisor. Supervisors are also Team Members as they report to Managers (just a custom field in the Team Member CPT i.e., Cashier, Supervisor, Lead Supervisor, Shift Manager, Manager)
4. Any Supervisor within the Department can view any Team Member in that Department irregardless of his/her Supervisor.
5. Only the Supervisor to whom a Team Member reports may add or edit that Team Member's information.
From the back-end, I have made the Supervisor a WP hierarchical parent of all the Team Members who report to him/her.
What I want to do is:
When adding a new Team Member. I want the creating Supervisor's post to "automatically" become the parent of the new Team Member without the Supervisor going to the back end. I understand I will need to use hooks (cred_save_data looks like the right one), I am just not sure how to do the parent assignment.
I could also use some guidance on restricting the editing to the creating Supervisor although I feel that using the Author restriction in Access will do the trick.
I should point out that this application has already been written entirely in PHP using session variables. I am porting it to WordPress for the blogging and other CMS aspects as well as the formatting/themes available.
Thank you for any guidance you may be able to provide.
Hello,
For the question:
When adding a new Team Member. I want the creating Supervisor's post to "automatically" become the parent of the new Team Member without the Supervisor going to the back end.
I suggest you try these:
1) setup post type "Supervisor" as parent post type of "Team Member",
2) setup a CRED form for creating child "Team Member" post:
https://toolset.com/documentation/user-guides/cred-forms-for-child-content/
Then user can create child "Team Member" posts for each "Supervisor" post, the post relationship will be setup automatically by CRED form, and in a single child "Team Member" post, you can display it's parent "Supervisor" post information easily:
https://toolset.com/documentation/user-guides/displaying-fields-of-parent-pages/