Skip Navigation

[Resolved] Updating fields (post title, custom and relationship)

The Toolset Community Forum is closed, for technical support questions, please head on to our Toolset Professional Support (for paid clients), with any pre-sale or admin question please contact us here.
This support ticket is created 6 years, 8 months ago. There's a good chance that you are reading advice that it now obsolete.
This is the community support forum for Types plugin, which is part of Toolset. Toolset is a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients and people who registered for Types community support can post in it.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 3 replies, has 3 voices.

Last updated by Luo Yang 6 years, 7 months ago.

Assisted by: Luo Yang.

Author
Posts
#628149

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

#629302

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?

#630077

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.

#630837

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/

The forum ‘Types Community Support’ is closed to new topics and replies.