Skip Navigation

[Resolved] error message Form type and post type do not match

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.

Author
Posts
#2162353

We have a members site here. The core where our problem is is two multistep forms where a user creates a profile. The first is a 4 step form, the second is a 9 step form. The 4 step form must be submitted and approved by admin, where after the 9 step forms will be completed. The 4 step form have the same first 4 same pages as the 9 pages. There is just an additional 5 steps added.

The structure in both multistep forms is the same. Created a form for each step of the 4 step form. Created a template for each of the post forms and inserted the post forms into templates.

This did work well and suddenly when we tested we had the problem of form type error. Because of the complex nature i Think it will be better if we give toolset access to the site. This is the more difficult issue. I raise the issue with toolset under message: #2158257 and figured the answer myself however this time i am not able to do it. This is very urgent as we had a training session with client that could not be competed due to both multistep forms not working

#2162583

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

Thank you for contacting us and I'd be happy to assist.

I've set your next reply as private so that you can share the temporary admin login details.

Please include the link to the page with this form and also the exact steps to see this error message.

Note: We recommend making a complete backup copy, before sharing the access details.

regards,
Waqar

#2162643

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for sharing these details.

I tried to log in to the admin area, but it is showing the message "Error: Activation key has sent".

Can you please let me know what else is needed, in order to log in?

Note: I've set your next reply as private again.

#2162695

Hi Waqar,

Sorry for the over sight. I did fixx the problem. We use an email verification system when user is created by front end form. I however created your login directly via the dash board and it still required the verification. I have subsequintly veryfied the account so you should not have any problems accessing the site.

Regards

#2162833

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for enabling the admin access.

If you'll check the "Profile Completeness" page, the edit post form "Update Editors Profile Step 01" is added with the option to edit the current post.
( screenshot: hidden link )

But this would've only worked if it was added on a single "Editors Profile" post or the target post's ID was provided through the shortcode attribute "post".
( ref: https://toolset.com/documentation/programmer-reference/forms/cred-shortcodes/#cred_form )

You're seeing the error message, because the form to edit an "Editors Profile" post is being asked to edit the "Profile Completeness" which is a page.

To make this work, you'll have to create a view on the page, that shows the target "Editors Profile" post that you want to edit. Inside that view's loop, you can add this form and it will work.

I couldn't understand how you're linking the "Editors Profile" posts with the currently logged-in user or how the members would reach to the "Profile Completeness" page from the "List New Members for Approval" page.

If could share some more information about this link, I'll be able to share some more suggestions.

#2162903

Thank you for you reply Waqar,

Let me give you a bit of extra information on the structure, and intent of this website, and this will hopefully clarify the case.

The abstract:

The site is a Guild for authors that can be hired to perform various functions from proofreading to editing documents. Each Editor/user must have a WordPress user account for this we have created a user registration system.

Once the editor/user has been registered and verified on WordPress they must then create a profile in the member's section. The member's section is made up of one CPT ( Add New Editor) and all the custom fields have been set up there.

Once the user has been registered they are then routed to the following page
hidden link; that contain the "new editors step 1" post form (id 1391) that is nested in a content template "new editors form step 1" id 1402 and this is the template for the page hidden link.

There is a function that is executed once the page is updated

 add_filter('cred_success_redirect', 'step2_redirect_func',10,3);
function step2_redirect_func($url, $post_id, $form_data)
{
    if ($form_data['id']==1391)
    {
       	$arr = array('content-template-id'=>1403); /*the step 2 template ID*/
        $url = add_query_arg($arr, $url);
    }
    return $url;

So once the "post form" has been updated the next form is then opened "new editors step 2 " id 1439" nested in template "new editors form step 2" id 1403.

There is then a function

add_filter('cred_success_redirect', 'step3_redirect_func',10,3);
function step3_redirect_func($url, $post_id, $form_data)

{
    if ($form_data['id']==1396)
    {
       $arr = array('content-template-id'=>1404);  /*the step 3 template ID*/
        $url = add_query_arg($arr, $url);
    }
    return $url;
}

this function as with the first one then opens up the next screen for steps 3 and 4 respecctively.

Once the 4 th step has been completed the profile is then presented to the admin for approval.

Once the approval has been granted the user is notified where after they must then complete the profile completeness page

They are supplied with a link to open the profile completeness page

hidden link; ( this is where the problem is now manifesting)

The process here is exactly the same as add new members profile.
From this point on the editor/member will now complete the fields in the custom post type "
add new editor. " the first form added a new editor profile with a limited number of fields.
At this stage the profile completeness form does have the same content on the first 4 pages as what was on the "add-new-member-profile" page. Once they have entered past the first four "steps" they will then be able to complete the non-updated fields in the CPT.

Step 1
The structure here is the same:
page - /profile-completeness with a template
"Editors profile completeness form 1" id 3834"
with a nested post form
"Update Editors Profile Step 01" id 1437
with a filter function:

add_filter('cred_success_redirect', 'step2b_redirect_func',10,3);
function step2b_redirect_func($url, $post_id, $form_data)
{
    if ($form_data['id']==1437)
    {
       	$arr = array('content-template-id'=>1551); /*the step 2 template ID*/
        $url = add_query_arg($arr, $url); steps 
    }
    return $url;
}

This process is then completed in 8 more steps. I am giving you step 2 so you can establish the pattern

Step 2
content template "Editors profile completeness form 1" id1551"
with a nested post form
"Update Editors Profile Step 01" id 1439
with a filter function:

add_filter('cred_success_redirect', 'step3b_redirect_func',10,3);
function step3b_redirect_func($url, $post_id, $form_data)
{
    if ($form_data['id']==1439)
    {
       	$arr = array('content-template-id'=>1552); /*the step 3 template ID*/
        $url = add_query_arg($arr, $url);
    }
    return $url;

This process continues through all 9 steps until the profile has been completed.

The first phase works like expected it is at the start of the second phase that the error is generated.

Christian Cox has been instrumental in helping us set up this structure. He did supply us with this link https://toolset.com/course-lesson/how-to-create-custom-searches-and-relationships-for-users/#how-do-i-prevent-users-from-creating-more-than-one-contractor-post to explain how the dependencies will work from the user to the editor's profile. the section about implementation - showcase explained the dependencies.

I hope this will give you a bit more clarification on the process.

#2163529

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for sharing these details.

From this, I understand that for every user who registers, there will exist an "Editor Profile" type post, for which this user will be set as the author.

Note: the user will be automatically set as the post author, when he/she will submit the form to create a new "Editor Profile" type post.

- In the content template "Editors profile completeness form 1" for the "Profile Completeness" page, I've created a new view "View to show currently logged in editor profile".

- The view is set to show exactly 1 "Editor Profile" post, where the author is the same as the currently logged-in user.
( screenshot: hidden link )

This means whenever a user will visit this page, this view will bring only that 1 "Editor Profile" post, for which the current user is the author.

- Next, I dragged the existing form block for the form "Update Editors Profile Step 01", inside this view's loop. This way the form will know which "Editor Profile" post needs to be edited and won't show the error message "Form type and post type do not match".

To confirm if this setup is working, I'll recommend visiting this "Profile Completeness" page, as a user who has created an "Editor Profile" post and you'll see the edit form.

You can reuse this same view on any page, where you need to change the scope from the current page to the current user's "Editor Profile" post.

Tip: "Author" field is not enabled for the "Editor Profile" post type and you can enable it from WP Admin -> Toolset -> Post Types and editing the settings of this post type.
( screenshot: hidden link )

#2164307

Hi Waqar ,

Thankyou for your help. It seems to be working. There is however one major problem we face and we need very verry urgent assistance as we have a training session planned for the client in about 4 hours and this must be working by then.

when we open the content template (CT) :
Editors profile completeness form 1 and save the post Form (PF)
Update Editors Profile Step 01 in the block it works .

When we move over to
(CT) Editors profile completeness form 2
(PF)Update Editors Profile Step 02
and save it still works

When we move over to
(CT) Editors profile completeness form3
(PF)Update Editors Profile Step 03
and saves it override the CT no 2 with the record of nr 3.

So at the end all the templates are sitting with form 9.

Please we need this addressed as a matter of urgency.

#2164487

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thanks for writing back.

I see the view that I suggested in my last reply is included only in the content template "Editors profile completeness form 1" and not in the subsequent templates (e.g. Editors profile completeness form 2, Editors profile completeness form 3 and so ).

Here is what you'll need to do:

1. Open the template "Editors profile completeness form 2" and remove any existing blocks from it.

2. Insert a "View" block and select the "View to show currently logged in editor profile" as the existing view.
( screenshot: hidden link )

3. When the view has been inserted, you'll see the options to either edit the original view or edit its copy.
( screenshot: hidden link )

As you don't want to change the original view used in the first template (Editors profile completeness form 1), you'll select the option to edit its copy.

4. This will create a copy of that view in this content template and you'll change the form inside this view from "Editors profile completeness form 1" to "Editors profile completeness form 2", as this template is the second one in the series.
( screenshot: hidden link )

As a result, a user viewing the first template will see the first edit form, and the user editing the second template will see the second form.

You can then repeat these steps for the remaining 7 content templates too.

#2164933
No editor profile found.png
No editor profile found image 2.png

HI Waqar,

I did follow your instructions and added the view to all the templates. During testing the system worked well, we did the first four screens that were then approved by the admin. The approval mail then went out and when the profile completeness page opened and gave an error "No Editor Profile found for the current user" however it was created and approved in the first step forms.

I am attaching screen prints

#2165481

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Can you please share some information about which user's profile you were trying to edit and were you also logged in as that same user?

It would also help if you could share that user's username and password too.

Important note: The view that I created will only show the current user's editor profile, if it is in the published state. If the editor profile post does not have a published status, the view will not be able to find that editor profile post and you'll see the message that you shared.

If you're setting some different status to your editor profile posts during these forms are being used, then you'll need to add a query filter in the view's setting to show posts having that specific status.
( example screenshot: hidden link )

Since you've placed multiple copies of this view in different content templates, you'll need to apply this change in the post status query filter in all of the copies where the editor profile post is expected to be in a different status than "published".

Note: I've set your next reply as private.

#2168619

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

I've checked the content template "Editors profile completeness form 2" and the view inside is set up properly.

For the test user "Olivier Herman" I couldn't find any "Editors Profile" posts, which is why, when I log in using that user and visit the "Profile Completeness" page ( /profile-completeness/ ), I see the message "No Editor Profile found for the current user."

I do see a couple of deleted/trashed "Editors Profile" posts named "Olivier Herman" but I'm not sure how and when they were deleted.

I used the new user form at the /new-user-registration/ page and created a new test user.

Next, I logged in using this test user and used the "Edit Profile" link from my "account page" and completed the series of forms to generate my "Editors Profile" post.

After, I visited the page /profile-completeness/ it showed me another series of forms, and that series of forms, also completed successfully.

I'll recommend testing this setup again and let me know if I've missed any detail.