Skip Navigation

[Resolved] Create “Alumno” and “Memoria” in two steps with 2 forms

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

This topic contains 10 replies, has 1 voice.

Last updated by Minesh 1 month ago.

Assisted by: Minesh.

Author
Posts
#2832383

Tell us what you are trying to do?
The goal is to allow the user to create a Alumnos (students) and a Memoria (Memory) in two steps (without PHP code for creation), ensuring that the Memory is automatically linked to the newly created Student and inherits the "Camada" (graduation year) Taxonomy.

Alumnos CPT is related with Memorias CPT as one-to-many and both shared the "Camada" taxonomy.

I've created an input form with Alumnos including de camada taxonomy

My idea is that upon submission of this form, it redirects to the page containing the "Memoria" creation form, and this form passes the parameters to link it to the Alumno and Camada.

However, I couldn't find a way to do this using the form editor.

What is the link to your site?
hidden link

Page with Alumnos Form:
hidden link
hidden link

Thank you

me

#2832472

Christopher Amirian
Supporter

Languages: English (English )

Hi,

Welcome to Toolset support, If you want to achieve this, Submit Alumno ➜ land on that Alumno’s single page ➜ show a Memoria form there that is already linked to this Alumno and pre-filled with the Alumno’s Camada.

Then you need to do as follows:

Step 1 — Alumno form

Build a normal post form for Alumno and include the Camada taxonomy field.

Step 2 — After submit action

In the Alumno form Settings → After visitors submit this form, choose Go to the post (i.e., the newly created Alumno single).

Step 3 — Put the Memoria form on the Alumno single template

Edit the single-Alumno (or its Content Template) and insert the Memoria create form on that page.

Step 4 — Auto-link the parent (Alumno)

In the Memoria form, include the relationship/parent field (e.g. @alumno-memoria.parent) and set it to use the current post as the parent.

For more information:
https://toolset.com/course-lesson/selecting-parent-posts-when-using-forms-to-create-child-items/

https://toolset.com/forums/topic/set-relationship-field-default-value-to-current-post/

Step 5 — Pre-fill Camada on the Memoria form from the current Alumno

Add the Camada taxonomy field to the Memoria form and set its default from a shortcode that reads the current page’s term (the Alumno page you’re on). For example, set default to the term slug via:

[wpv-post-taxonomy type="camada" format="slug" item="$current_page"]

https://toolset.com/documentation/programmer-reference/forms/cred-shortcodes/

Now, the User creates Alumno → WordPress opens the new Alumno page → the Memoria form on that page already knows the parent Alumno and has Camada pre-selected to match the Alumno’s Camada.

Thanks.

#2832572

Here is a screen recording with the problem that I found with the taxonomy field in a form.

hidden link

thanks

#2832890

Christopher Amirian
Supporter

Languages: English (English )

Hi,

Thank you for the video. That is strange. I can try myself and see if I can find why this is happening. I'd appreciate it if you could give me the URL/User/Pass of your WordPress dashboard after you make sure that you have a backup of your website.
It is absolutely important that you give us a guarantee that you have a backup so if something happens you will have a point of restore.

Make sure you set the next reply as private.

#2833285

Any news?

#2833376

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Christopher is on vacation. This is Minesh here and let me jump in here.

I would like to know why you assigned year taxonomy to both post types?

Can I have workflow and problem URL and step by step information on what page you added your form and where exactly with what link you stuck. Please share all required informtion with URLs and share details whats your expected result on what URL.

I have set the next reply to private which means only you and I have access to it.

#2833383

This is a school, and students graduate every year. The "Camadas" (Graduation Classes) taxonomy is what groups these students by their graduation year.
The idea is that a student can add themselves as such by leaving their first and last name, email, and graduation year ("Camada" taxonomy).
And then, they can add an anecdote from their time at the school (CPT "Memories").

The goal is that, if a student belongs to the 1975 class, for example, all the anecdotes they upload to the web will be grouped under the same class (1975). This way, I can later view the archive of all the memories that different students from the 1975 class have uploaded.

I could also view an archive of the students for each class.

This is the page with the form to enter a student's data: hidden link

When the data is submitted, I direct them to their student page, just as Christopher explained. I added a link there to "Add an anecdote," and this takes them to the page with the anecdote submission form.

The student's name is perfectly associated with that anecdote. What I haven't been able to achieve is for the same "Camada" (class) category to be assigned to the "memoria" as well.

#2833384

You can use the credentials that I created for Christopher.

#2833391

I just realized you had set the reply to private, but I don't know what I did that made it appear as a normal reply.

I didn't share any website information, though.

If you still need login details because you can't use Christopher's, please send me another private reply.

Thanks

#2834436

Hi, any news?

thank you

#2834698

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

With the following page:
- hidden link

I've replaced the following shortcode:

[cred_child_link_form form='2890' parent_id='-1' text='Agregar nueva anécdota' target='_self']

With

<a href="/formulario-para-crear-memoria/?parent_alumno_id=[wpv-post-id]&camada_id=[wpv-post-taxonomy type='camada' format='id']">Agregar nueva anécdota</a>

Then with the following form:
- hidden link

I've added the following custom JS:

jQuery(document).ready(function($) {
    // Helper function to get URL parameter
    function getUrlParam(name) {
        const results = new RegExp('[?&]' + name + '=([^&#]*)').exec(window.location.href);
        return results ? decodeURIComponent(results[1]) : null;
    }

    // Get camada_id from URL
    const camadaId = getUrlParam('camada_id');

    if (camadaId) {
        // Set the value in the select named "camada[]"
        const $select = $('select[name="camada[]"]');
        if ($select.length) {
            $select.val(camadaId).trigger('change');
          
        }
    }
});

Now, when I visti the following page:
- hidden link

And click on the link "Agregar nueva anécdota", it redirect me on the following page:
- hidden link

And I can see the camada taxonomy option value is pre-selected.

Do you want this solution or you want to hide the camada taxonomy on the above memory page and attach the taxonomy via cred hook.