Skip Navigation

[Resolved] Post type title search and next action based on the result

This support ticket is created 2 years, 10 months 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.

This topic contains 6 replies, has 2 voices.

Last updated by chelhwanS 2 years, 10 months ago.

Assisted by: Christopher Amirian.

Author
Posts
#2480407

Tell us what you are trying to do?
Post type title search and next action based on the result

https://toolset.com/forums/topic/frontend-search-filter-by-post-types/

What is the link to your site?
thedang.co.kr

************
Informing the user of a specific code to receive a free blood glucose meter, the user enters the site and enters the code, and provides a free blood glucose meter if the code is in the site's database

The process on the site is as follows.

1. Enter the free blood glucose meter code
2. Search if the code exists in the site database
3. If there is a code on the site, change the content of the post type to "2" and go to a specific page
“thedang.co.kr/shop”
4. If there is no code on the site, the "No Code" notice.

The above is the work order

post type: free diabetes meters.
Title: Blood glucose meter code , Content: Unused: 1, Use: 2

I don't know how to use the block editor View Block.
I'm trying to use the classic editor, but I don't know how to apply it to the block editor

I am asking for help because there seems to be a lot of processes that search a certain database and proceed to the next operation based on the result.

If it is not appropriate to apply the view block, please provide a suitable code example.

#2482077

Christopher Amirian
Supporter

Languages: English (English )

Hi there,

It seems that you want to replicate the settings mentioned in the ticket that you provided.

To do that you need to enable the legacy mode and use that instead of the block editor.

Here is how to do so:

https://toolset.com/course-lesson/enabling-legacy-version-of-toolset-views/

If you need more details on how to add a search view in legacy mode:

https://toolset.com/documentation/legacy-features/views-plugin/

Thank you.

#2482795

What you have explained now is about the flow of showing search results after a search
I don't want to show the search results, but I want to perform different actions according to the search results.

If a search is performed and there is no value, the site informs the user that there is no value, and returns to the previous page.

I did a search, and if there is a result value, I want to go to the field group of the result value, change the value of one of the fields in the field group, and apply moving to another page.

View is Search -> Show results.

I want to implement the flow of search -> find result, and execute different actions according to the result.

#2482871

Christopher Amirian
Supporter

Languages: English (English )

Hi there,

This is not possible with normal Toolset flow. What you want to do needs a huge amount of custom coding.

I will try to give the big picture on how to do it but the implementation is what you need to do.

- The first thing is that you need to create a custom field and assign to the post type to add the meter numbers there that will be checked later.
- Create a view and setup the top search box with the custom field in question so the customer can enter the number to check from.
- I think if you split the view and the search result it will be a good idea:
https://toolset.com/course-lesson/displaying-search-results-on-a-different-page/
- After that, you need a way to capture the result before redirecting to the search page.
- To do that you can use the function below:
https://toolset.com/documentation/programmer-reference/views-api/#get_view_query_results
- It will give you the result in an array. If the array is empty then redirect to a page that you show the message. You can learn more about redirection in PHP here:
https://stackoverflow.com/questions/768431/how-do-i-make-a-redirect-in-php
- If the array has result, you will need to change the custom field value and then redirect. The only way to update the value of a custom field is to save the post associated with that field and it is the save_post WordPress hook, Here is how to do so:
https://toolset.com/documentation/customizing-sites-using-php/updating-types-fields-using-php/

Please kindly consider that this is what I come up with and might not the ultimate solution. I will also ask my colleagues to see if they have other ideas or not.

Thank you.

#2483649
221026-2.png
221026-1.png

I think I may have to study from now on and make code in php and html. I am 65 years old... --;;

Before that, I wanted to solve the problem with the View, so I made the view with the classic editor. (free meter view2)
And I tried to import the view created by the classic editor using "field and view Block" in the Gutenberg editor.

But only "Loading..." continues.
What did I do wrong?

The content created with the classic editor is attached as an image.

New threads created by Christopher Amirian and linked to this one are listed below:

https://toolset.com/forums/topic/split-loadin-when-trying-to-load-a-classic-view/

#2484725

Christopher Amirian
Supporter

Languages: English (English )

Hi there,

Please check the answer in the ticket that I split as the last reply was a new question.

Thank you.

#2484967

It's the same thing....