Home › Toolset Professional Support › [Resolved] 3 user forms to property listing, qualification, schedule? (Part 2)
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 |
---|---|---|---|---|---|---|
- | 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)
Related documentation:
This topic contains 27 replies, has 2 voices.
Last updated by Nigel 4 years, 8 months ago.
Assisted by: Nigel.
OK. Using the code above in the Toolset settings > Custom code allows the existing form redirect from User Registration -> Property Detail Form -> Qualification to include an additional post ID in the URL. Specifically:
We start at:
hidden link
On form submit redirect to:
hidden link
On form submit redirect to:
hidden link
Assuming that is what we are looking to occur?
I also tried working up to the next step you have above of using the toolset_connect_posts function, but ended up with an error in trying to link the ID for the Schedule form to the ID of the Property form. I've attached a screenshot of existing Relationships, Post Forms, and error I get trying to modify the example code snippet to match my forms' IDs.
Languages: English (English ) Spanish (Español )
Timezone: Europe/London (GMT+00:00)
That looks like it's working as expected, the id=129 parameter means that on the listing-qualification page we know which property was created in the previous step.
So the next step is, when the form to publish a qualification post is submitted, we need to connect it to the list post created by the previous form, as well as continuing to pass along the id of the listing so that it is available in the next step.
Rather than writing several different code snippets we can expand the existing snippet.
You'll need the following:
function ts_redirect_forms( $url, $post_id, $form_data ){ if ( $form_data['id'] == 14 ){ // Edit ID as required // code for form in Step 2 // Append URL parameter with post ID to redirect URL $url .= '?id='.$post_id; } elseif ( $form_data['id'] == 123 ){ // Edit ID as required // code for form in Step 3 // first connect new post if ( isset( $_GET['id'] ) ){ $child_id = $_GET['id']; toolset_connect_posts( 'relationship-slug', $post_id, $child_id ); // Edit relationship slug // Pass on the original post ID again $url .= '?id='.$child_id; } } return $url; } add_filter( 'cred_success_redirect', 'ts_redirect_forms', 10, 3 );
You need to make sure the IDs of the forms are correct, and you'll need to edit the relationship slug for the listing-qualification relationship.
Can you verify that works?
The last post form to create the property schedule is ID 128 so I updated the code above to the code below and now get an error stating:
syntax error, unexpected 'if' (T_IF) in /home1/reknownc/public_html/b4/wp-content/toolset-customizations/toolset-credsuccessredirect.php on line 19
A problem occurred when executing snippet "toolset-credsuccessredirect". The result of include_once is: ""
<?php /** * New custom code snippet (replace this with snippet description). */ toolset_snippet_security_check() or die( 'Direct access is not allowed' ); // Put the code of your snippet below this comment. function ts_redirect_forms( $url, $post_id, $form_data ){ if ( $form_data['id'] == 14 ){ // code for form in Step 2 // Append URL parameter with post ID to redirect URL $url .= '?id='.$post_id; } elseif ( $form_data['id'] == 128 // code for form from step 3 // first connect new post if ( isset( &_GET['id'] )) return $url; } add_filter( 'cred_success_redirect', 'ts_redirect_forms', 10, 3 );
OK, I confirmed the error I was seeing appeared to have been a copy and paste issue. Recopied and redirect is now working to the 3rd form for schedules (which appear to be broken because I was trying to use a simple repeating field group to allow users to just enter a day of the week, then time to simplify the schedule variables.
Another question: is there a reason the properties that are created through this workflow come up as random auto drafts? I've attached an image below to illustrate what I'm seeing.
Languages: English (English ) Spanish (Español )
Timezone: Europe/London (GMT+00:00)
Those automatically generated titles are because your form doesn't include a post title field, and titles are required by WordPress.
You either need to include a post title field in the form, or you'll need to auto-generate your own preferred titles, for which you could use the cred_save_data hook, for example, to replace those titles.
In the documentation for cred_save_data the final code snippet example demonstrates generating post titles: https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data
Thanks Nigel, you have been a great help. So I just added a field for the Property name and that seems to have solved for it.
Concerning the next phase of checking a potential applicant’s form entries against the owner’s qualification entries that we just created, is that a workflow that’s better to open a new support ticket on or would we work through that in this ticket as well?
Happy to provide more context on that as well, but could you confirm if this support thread is or is not publicly searchable? I know specific URLs are hidden, but is there a way to ensure the full ticket attachments and discussion is only between myself and Toolset as well?
Thanks in advance.
Languages: English (English ) Spanish (Español )
Timezone: Europe/London (GMT+00:00)
Sorry for the delay getting back to you, I got pulled for some other urgent tasks yesterday.
Let's wrap up this thread, and resume in a new thread, but I'll continue to handle this for you as I'm familiar with the project.
But, before I split this into a new thread to get details from you, I should point out that while I can set up individual private replies I can't make the whole discussion private.
Do you want me to go ahead and split this into a new thread. If so you can then give me more details about where we are going next.
Hi Nigel, could you mark this response private?
I have a bit of this outlined off the previous thread below and would love to have the first post on that one marked as private to Toolset Support as well.
The short answer is that I’d like to allow owners to have a Property view that sends a potential applicant through a similar workflow to what they, themselves, completed to setup the listing. Specifically:
Does this make sense? Happy to describe in more detail if needed.
Earlier Thread on Topic:
https://toolset.com/forums/topic/3-user-forms-to-property-listing-qualification-schedule/#post-920090
Languages: English (English ) Spanish (Español )
Timezone: Europe/London (GMT+00:00)
Hi Cliff
I can only set up private replies before you post them, not after. I can go back later and edit some of your replies to redact the text, but I won't do that while I still need to be able to read them myself.
Looking at the above, my concern is whether you are able to set this up yourself without my developing it for you step-by-step as we've done so far.
I'm happy to help you familiarise yourself with the Toolset APIs, but I can't develop your site by stealth if and when you should really be using a developer to do it for you, I just want to be clear on that.
Looking at the above I think I need some more details about the Qualifications and how they work.
The property owner adds Qualifications to their property.
For the sake of argument I'm guessing these are something like "income > $50k" and "college educated" is a checked checkbox.
I can imagine populating a form with the qualification posts that are connected to the property, but I'm confused about how a qualification of "income > $50k" would know that the form should ask for the income of the applicant as a number to be able to compare, while the qualification for "college educated" should know to display a checkbox that needs checking.
Can you give me some clear examples of how you envisage this part working in practice?
Understood on the potential need for developers. In parallel to this support thread, I have reached out to several of those listed in the catalog, but want to ensure I am doing all I can with the basic Toolset functions prior to handing over the design and more advanced code to them.
To clarify, what I need to know is whether I can have a Qualifications post entry that an owner attaches to a Property be compared to an entry on a different form from an applicant to that property. The idea would be to have minimum standards for applying to a Property, whether that be a credit score, income, etc.
I have worked with other third party form plugins that can accomplish this by setting the actual entry value for the database as a number, while the front-end user’s form selection is something more useful or descriptive. An example would be an applicant having a “700-750 credit score” as the selection, but actually entering “700” as the entry value in the database.
I do not see that capability in the form creation UI for Toolset, but perhaps there is more than this rudimentary way to compare one form’s entries to another form’s entries?
The other challenge here (which we appear to have solved for in the form handoff workflow above) is that we can identify an entry by Property+Form versus a specific Entry ID (which could change if an owner makes a new form submission that changes the entry ID). Does that make sense?
Here’s the example of the entry values vs form values.
Languages: English (English ) Spanish (Español )
Timezone: Europe/London (GMT+00:00)
What's shown in your screenshot is simple enough to replicate.
When you create a select custom field with Types and add options, the options take a display value as well as the content that is actually stored, so in my screenshot I have text labels for numeric values, but these text labels could equally be numeric ranges such as in your example.
And I understand from the last update that the property owner will submit a qualifications post attached to the property, but this qualification post has a fixed set of fields to be completed (e.g. credit score, income), and the applicant will submit a post that has the same fields to compare against the qualification post field values.
OK, that makes sense.
You'll need to make a set of parallel fields for the applicant form that tally with the qualifications fields. (You can't re-use the same fields, because your applicant will be entering a specific value for, say, income, rather than the dropdown with ranges that the qualification post offers.)
I would set the form up to redirect to the failure thank you page by default.
Then you will again use the cred_success_redirect hook, and this time the code is going to do all the heavy lifting of checking each of the fields against the qualification counterpart, to arrive at a pass or fail decision, and if pass you can override the default redirect so that it instead redirects to the intended page (the schedule page attached to the property).
So I think what you want is do-able, yes, it's a question of working through the detail in custom coding.
Thanks Nigel. I'll reach out to a developer on the custom code piece since I would not really know where to begin on checking values.
However, on the topic of the parallel fields for the tenants, I created a new/parallel set of custom fields for the Qualifications in the Dashboard and tried to add these into a new post form, however when I trim out the parallel custom fields for the Owner qualifications and try to save, I just get an endlessly spinning save circle.
Thinking it was a form error, I went back, deleted the form, and tried to recreate: same issue. Tried logging into the site with a different web browser and trying again, same issue.
Is any way of knowing what may be happening when a post form will not save? Logs that are generated from Toolset itself?
Languages: English (English ) Spanish (Español )
Timezone: Europe/London (GMT+00:00)
Are you unable to create new forms generally, or specifically for this post type with these fields?
To see your PHP logs, if you haven't already, turn on the debug log by editing your wp-config.php file and change the line with WP_DEBUG like so:
define('WP_DEBUG', true); define('WP_DEBUG_LOG', true); define('WP_DEBUG_DISPLAY', false); define('WP_DISABLE_FATAL_ERROR_HANDLER',true);
That will create a debug.log file in your /wp-content/ directory which you can examine in any text editor. Try the steps of creating the form again and then inspect the log. If you don't find the debug.log file it means it didn't generate any warnings or errors.
You should also be looking in your browser console for JS errors.
Let me know what you find.