Skip Navigation

[Resolved] Passing URL Parameter

This support ticket is created 4 years, 1 month ago. There's a good chance that you are reading advice that it now obsolete.

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
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: Africa/Casablanca (GMT+01:00)

This topic contains 9 replies, has 3 voices.

Last updated by Jamal 4 years, 1 month ago.

Assisted by: Jamal.

Author
Posts
#2107569

Hi,

It would be helpful if Jamal can handle this query, since he now understands the functional requirement of the application.

This view output page (hidden link) has multiple enquiry outputs, user would be selecting one of these and needs to respond with their own comments in the response form (after clicking Respond Now button)- hidden link

I want to reproduce details of the selected enquiry (Enquiry Name, Mediapro Name, Enquiry Details, and Response Date) in the response form as Non editable fields, for respondent's reference.

Please help.

Thanks,
Vikas

#2107587

Hello Vikas,

To better assist you with this, I still need to know some functional aspects, based on the following(what I understood so far):
- MediaPros custom post type is meant to represent users that are Media Professionals. The users that will create Enquiries.
- Corporate Communications users will reply to these Enquiries, by creating responses.
- Media Professionals should be notified of the responses and should be able to check them.

Keep in mind that users who create posts. Posts cannot create posts. Posts can be related to other posts(different types) using Toolset relationships.

So, my questions are the following, please answer each of them so I can better understand what you were trying to do, I might suggest a better solution:
1. What is the Enquiry ID field, in the Field Group for Enquiries, meant for? Is it a value that the Media Professional should enter, or should it be generated by the system and be unique?
2. What are the following "Post Reference" fields, in the Field Group for Responses, meant for?
- Selected Enquiry ID
- Selected Enquiry Details
- Media Pro of Selected Enquiry

For the 1st question, if the Enquiry ID should be a unique value generated by the site, why not use the post's ID which is unique by design. It is the only way we can connect posts to post in a Toolset relationship.

For the 2nd question, if the Post Reference fields are meant to link the response to its related enquiry and the Media Pro that has created it. I would suggest another approach. Use the existing relationship "Enquiries Responses".
hidden link
And based on the relationship to the Enquiry post, we can get the related Media Pro. I can elaborate on this, but let's first see your answer to my above questions.
If my assumptions are correct, and because users create post(not post), we'll find a way to link the user that has created the Enquiry, to the relevant MediaPros post that represents him.

Let me see your answers, and we can go further to what I understood you want to achieve(display the enquiry data(as readonly) in the response form).

#2107737

Hi Jamal,

Below are my answers against your questions -

1. What is the Enquiry ID field, in the Field Group for Enquiries, meant for? Is it a value that the Media Professional should enter, or should it be generated by the system and be unique? -

Answer - Enquiry ID is meant for enquiry identification, needs to be auto-generated by system and unique

2. What are the following "Post Reference" fields, in the Field Group for Responses, meant for?
- Selected Enquiry ID
- Selected Enquiry Details
- Media Pro of Selected Enquiry

Answer - To capture the enquiry selection of the user in the response database - which enquiry user has selected and responded to.

For the 1st question, if the Enquiry ID should be a unique value generated by the site, why not use the post's ID which is unique by design. It is the only way we can connect posts to post in a Toolset relationship. -

Answer - That's great idea. Please help how to use it here.

For the 2nd question, if the Post Reference fields are meant to link the response to its related enquiry and the Media Pro that has created it. I would suggest another approach. Use the existing relationship "Enquiries Responses".
hidden link
And based on the relationship to the Enquiry post, we can get the related Media Pro. I can elaborate on this, but let's first see your answer to my above questions.

Answer - I tried using Enqquiries Responses, but I guess this relationship will only pull all responses to an enquiry. We also need to capture who has selected which enquiry and given what response.

Hope I am able to answer your queries.

Thanks a lot.
Vikas

#2107751

Thank you. I just need to clarify one more thing before wrapping up everything.

My assumption is correct "MediaPros custom post type is meant to represent users that are Media Professionals", right?
However, right now, there is only one user in the database. Are you going to let users use the site? If yes, you would want that each Media Professional user has only one post from the MediaPros custom post type, right?

Please check this article and let me know if that's similar to what you are looking to build https://toolset.com/course-lesson/how-to-create-custom-searches-and-relationships-for-users/

#2107809
mediapros.jpg

Hi Jamal,

Your understanding is correct.

Mediapros are for Media professionals and they would be creating / updating their profiles from frontend (once I create access page for them). Article link you have sent is exactly what I am trying to build.

I have created 4 records for mediapros (see screenshot), not sure which one record you are referring to.

Thanks,
Vikas

#2108531

Hi Jamal,

Let me know if you want me to further detail on anything.

Look forward to your revert.

Thanks,
Vikas

#2109271

Nigel
Supporter

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

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

Hi Vikas

Jamal's work week is Friday-Tuesday so that he is able to offer support at the weekend.

It looks like he has gone into quite a bit of detail with you here already to understand the problem, so if it is okay I'll leave it to him to follow-up tomorrow when he returns.

#2110261

Hello and my apologies for the late reply, but I do not work on Wednesdays and Thursdays as you may check on my profile page https://toolset.com/forums/users/jamal-b/

Short answer: We can't really achieve what we want on this ticket, without having some requirements. The ability to mirror user information into the custom post types. Currently there is only one user in the system(interactiveware).

Long answer:
We'll create a user and make him the author of his respective post(MediaPros). Let's work with the "Shereen Bhan". I have created a user for him(shereen: hidden link).
Then I activated the authors' option in the custom post type settings. Check this screenshot hidden link
And made the user be the author of his post/profile(MediaPros) hidden link

I choose this user because his profile(MediaPros) is already connected to an existing enquiry Speaker Opportunity: (hidden link)
This way, we can pull all the data(enquiry, mediapro) in the response form, by using the URL parameter, and the relationship(MediaPros<>Enquiries).

We won't need to pass the MediaPros ID in the URL because we'll pull it from the Enquiry.

I don't think that these fields need to be saved in the Response Form. We should, only, save the relationship/link between the response post and its parent enquiry post. So, we will use some HTML instead of Toolset Forms fields. It would be just text instead of readonly fields.

First, we need to update the link in the "Respond Now" button to use the Enquiry post ID, instead of the"Enquiry ID" fields, that should IMHO be removed from the custom fields. This way we will pass the Enquiry post ID in the URL with the parameter "eid":

<em><u>hidden link</u></em>;

Then, we will update the form to display the Enquiry title and details and the MediaPros title. We will be able to do the above by using the item attribute of Toolset shortcodes, and wpv-search-term shortcode. Read more here:
- https://toolset.com/documentation/programmer-reference/views/views-shortcodes/item-attribute/
- https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-search-term

We can pull the Enquiry details with the following nested shortcodes:

Selected Enquiry ID: [wpv-post-title item='[wpv-search-term param="eid"]']

Selected Enquiry Details:[wpv-post-body view_template="None" item='[wpv-search-term param="eid"]'] 

Getting the MediaPros title, is a little tricky because we can do nested shortcodes for another level. So, we will use an intermediary content template. A content template will ALWAYS render the information of ONE post. We'll pass the Enquiry ID to this content template. And inside of it, we'll display the parent MediaPros title. Please note that this content template is not assigned to any post type. Check this screenshot hidden link
This is how we will include the content template, not how we pass the Enquiry ID using the item attribute:

[wpv-post-body view_template="Parent MediaPros title"  item='[wpv-search-term param="eid"]']

And this is how we will put the MediaPros data inside the content template:

[wpv-post-title item="@mediapro-enquiry.parent"]

However, we need the response to be linked to the enquiry post. So, we will still use the relationship field and hide it using Javascript. Check this screenshot hidden link and we will hide it using the following Javascript in the form, check this screenshot hidden link

jQuery('div[data-item_name="select-@enquiry-response.parent"]').parent().hide()

We need to use the relationship field to make sure that the created response post will be linked to the parent Enquiry post.

I hope this is clear enough to showcase how you can pass the Enquiry ID through the URL, and display its data inside the form. While still ensuring that the created response will be linked to the Enquiry post.

Let me know if you have any further questions.

#2110463

Hi Jamal,

I was not aware of your off days. I was just concerned since you have been very prompt earlier and didn't reply for 2 days. Sorry for escalating it. I am still trying to understand the solution you have provided. I have few initial questions -

1) When we activate Author registration from front end and Author creates a Enquiry post, how do we make sure Author gets linked to the Post automatically.
2) How and where do we save this relationship link between the response post and its parent enquiry post?
3) How I have to create content templates whenever I create a page for pulling personalised data e..g., when media person logs in to view all enquiries posted by him or all the responses he has received.

I am still trying to understand it fully and may come back to you with more questions.

Thanks,
Vikas

#2110797

Hello Vikas, sure, ask as many questions as you need.

1) The link that we have between a user and its corresponding profile post is the author. We need to configure the form that creates the profile to make the user the author of the post. This way, if we want to get the profile of a user, we search for the post when he is the author. Check the query filters section of a view, and play with the query filter, you can set it to the author being the current user.

2) How? Using the Toolset relationship. Where? Either in the backend or in the frontend forms(using a relationship field). In the form for creating responses, the relationship field is the first one. If you remove it from the form, you will see it in the right sidebar, in the relationship fields section.

3) Well, first, you should note the difference between a content template and a view. Check our glossary for more details https://toolset.com/glossary/
A view is meant to query and display a list of posts. Where as a content template is meant to display one post. And you can mix them(use a view inside a content template, or use a content template inside a view). To answer this question(when media person logs in to view all enquiries posted by him or all the responses he has received) I would prefer to work on a separate ticket.

However, I think that first of all, you need to set up the forms and view to handle user profiles before working on enquiries and responses. If you can implement what is suggested in this article, that would help us a lot with what follows https://toolset.com/course-lesson/how-to-create-custom-searches-and-relationships-for-users/