Hi
I'm want to set the form fields instead of the drop-down menu
But that didn't work
Although I followed the explanation in the link below
01: https://toolset.com/documentation/post-relationships/how-to-build-front-end-forms-for-connecting-posts/
02: https://toolset.com/documentation/post-relationships/how-to-build-front-end-forms-for-connecting-posts/creating-new-connections-between-related-posts/
The steps you did are as follows:
steps 01: create new relations "So much to much"
steps 02: create form relations forms
steps 03: create template and add in relations forms
--
But only a drop-down menu appears
I'm want to set the form fields instead of the drop-down menu
But that didn't work
Hello, please allow me to clarify this. A Relationship Form cannot create new Student posts. It can only create relationships between posts that already exist. Similarly, a New Post Form cannot create many-to-many relationships between posts. It can only create posts. If you want to create a Student post from this page, you must insert a new Student Post Form. If you want to link an existing Student to this Course in a many-to-many relationship, that Student must already exist. Then you can use a Relationship Form to link the Student and the Course.
If you want to automatically link a Student and a Course from a new Student Post Form, it is possible using custom code and our Forms API and our Toolset Relationships API. We have documentation for those APIs available here, with code examples:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_connect_posts
Let me know if you have questions about this type of automation and I can offer some more guidance.
Excuse me if my question is not clear
Please see the attached picture
I mean how to show the child form in the front-end
thank you for help
You must create this Form, then insert it in the site somewhere. Go to Toolset > Post Forms and create a new child post Form. Then insert the new child post Form somewhere, for example, in the parent post Content Template. Click the "Toolset Forms" button to insert the new child post Form (see the screenshot).
Please note that you cannot place a new child post Form inside another Form. The parent and child Forms must be completed separately.
A Relationship Form cannot create new Student posts
I want students register in courses from the front-end?
You must create this Form, then insert it in the site somewhere. Go to Toolset > Post Forms and create a new child post Form. Then insert the new child post Form somewhere, for example, in the parent post Content Template. Click the "Toolset Forms" button to insert the new child post Form (see the screenshot).
Yes, sir, but when I do the student is not saved under any course
I want students register in courses from the front-end?
Yes, sir, but when I do the student is not saved under any course
If you want to automatically link a Student and a Course when a new Student Post Form is submitted, it is possible using custom code with our Forms API and our Toolset Relationships API. We have documentation for those APIs available here:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_connect_posts
Let us assume you place the new Student Post Form inside the Course Content Template. When the User submits the Form, you want to create a Student post and automatically link it to the current Course. You must follow these steps:
- Create a "number" generic field in the New Student Post Form called "current-course".
- Set the value of this field to be the ID of the current post:
[wpv-post-id item='$current_page']
- Use the cred_save_data API to trigger the toolset_connect_posts API when the New Student Post Form is submitted, for example:
add_action('cred_save_data', 'connect_new_student_and_course',10,2);
function connect_new_student_and_course($post_id, $form_data)
{
// if a specific form
if ($form_data['id']==12345)
{
if (isset($_POST['current-course']))
{
// connect the new student to the current course
toolset_connect_posts( 'relationship-slug', $_POST['current-course'], $post_id );
}
}
}
- Replace 12345 with the numeric ID of the new Student Post Form.
- Replace relationship-slug with the slug of the many-to-many relationship.
Let me know if you have questions about using custom code.
You can place custom PHP in a child theme's functions.php file, or you can paste the code into a new custom code snippet in Toolset > Settings > Custom Code.
- Replace 12345 with the numeric ID of the new Student Post Form.
Do you mean here to determine the course id number?
But I have, for example, 50 courses
Do I need to specify the id number on each course?
- Replace relationship-slug with the slug of the many-to-many relationship.
I did not understand this
thank you sir
The idea is sir
I want to work as directory courses
some Members register new courses
some Members register for those courses
- Replace 12345 with the numeric ID of the new Student Post Form.
Do you mean here to determine the course id number?
No. I mean you should go to Toolset > Post Forms and find the numeric ID of the new Student Post Form. I am attaching a screenshot here form-id.png showing the numeric ID of each Form in an example site.
- Replace relationship-slug with the slug of the many-to-many relationship.
I did not understand this
Find the slug of the many-to-many relationship by going to Toolset > Relationships. Then click "Edit" for the Students - Courses many to many relationship. You can find the slug of the relationship here. I am attaching a screenshot here relationship-slug.png showing the slug of an example relationship. My example relationship slug is book-chapter, so the code for my example would be:
toolset_connect_posts( 'book-chapter', $_POST['current-course'], $post_id );
You should replace book-chapter with the slug of your Students - Courses relationship.
Thank you sir This is very clear
But what if you want members to register new courses
Others join these courses
How to make the member open the course page and fill out the form
I don't completely understand, sorry! How is the Student post created for a new User? Is there a Form where new Users create Student posts, or is the Student post created in wp-admin by some administrator?
The action is as follows:
I have two members "Teachers" and "students"
1-the teachers-members create new course in front-end page
2-the students-members On the course page, view the registration new student form
Another example:
1- Members ask questions
2- Administrators respond to it via the form on the question page
Just that's all I want
I'm very sorry that I couldn't make the question well