Skip Navigation

[Resolved] select field in a cred post form

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 8 years 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
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 5 replies, has 2 voices.

Last updated by thomasP-2 8 years ago.

Assisted by: Nigel.

Author
Posts
#456057

Hi,

I use toolset for managing meetings between students and teachers of several schools
The relationships of content:
-----------------------------------------------
school > students
school > teachers
school > meetings
------------------------------------------------
school > students > meetings
school > teachers > meetings

When I create a form for meetings (post-type), i get fiels like that:
[cred_field field='_wpcf_belongs_teacher_id' value='']
[cred_field field='_wpcf_belongs_student_id' value='']

In the select field of the form are all students and all teachers from all schools.
How do i get only the specific students and teachers of a given school?

Thanks for your support
Thomas

#456092

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Thomas

That sounds familiar but I can't put my finger on it right now. I will keep looking and get back to you...

#456770

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Thomas

I still can't put my finger on it, I will need to work out a solution for you.

The one thing I am missing from your description is how do we know which school we want to limit the post relationships to?

The form which creates meeting posts, is it aware of which school it is creating posts for before it is rendered?

This will require some custom code on the front end, and depending on how and when the school is determined it may be possible to limit the teachers and students passed to JavaScript to just those from the required school, or it may be necessary to pass all teachers and all students and the schools they belong to.

#456808

Hi Nigel

Sorry, I unfortunately forgot to explain that the information which school is currently logged in comes from a session variable ($_SESSION['school_id']).
Is there a way to use it in the cred form?

#456889

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Thomas

That won't help when the CRED form is generated, but it does help when it comes to customising the parent post options once the form has been sent to the browser.

What is involved writing some PHP which for the relevant page where the CRED form is added will create an array of the relevant teachers and students that are possible parents of the to-be-created meeting given the school available from your session variable, and then make this available to jQuery on the front end using wp_localize_script.

(See http://codex.wordpress.org/Function_Reference/wp_localize_script and hidden link)

We can then use jQuery to remove the existing options from the select boxes and rebuild them to include just the possible parent posts according to the school using the array passed from our PHP code.

Does that sound like a viable solution?

Are you able to have a go yourself, or do you need some help implementing it?

#456897

Hi Nigel

Your reference to wp_localize_script() solves the issue.
Thank you for your patience and the excellent support.

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