Skip Navigation

[Resolved] Submitting CRED form to create new CPT breaks permalinks, CPT archive and Search

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

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 22 replies, has 2 voices.

Last updated by Shane 7 years, 2 months ago.

Assisted by: Shane.

Author
Posts
#482381

Please keep the URL of my website private, thank you.
I added debug information to his post, and I have another support topic where I added login details. Feel free to use these details if you need them.

I have the following problem:

I have a CRED form (form ID 53) to create new content - a custom post type (post type z********er asterisked because of privacy). The CRED form is linked to a Woocommerce product (ID 272) . When the form is submitted, the Woocommerce part works and a new post is created.

However, after the creation of this post, it is not visible in the front end (it is in the back-end)

The URL of the newly created post gives a 404, the post archive for the CPT is not working anymore and search forms for this CPT type are broken as well. When I delete the created new post, the problems do not disappear and I already had to have my site restored by the hosting company.

After restoring, the problem occured again, the post that caused is ID 821.

When I create a new post using the WP Admin, there are no problems.

Could you please look into this? Thank you!

#482383

I just noticed that the site only appears to be breaking in Chrome and not in Firefox and Safari. After restoring the site and before submitting the CRED form, it worked in all 3 browsers. After submitting the CRED form, the site breaks in Chrome.

#482453

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Jack,

Thank you for contacting our support forum.

It seems that something might be up with the permalinks, what I would recommend that you do is to refresh your permalinks by going to Settings -> Permalinks and then set the permalinks to default and check again to see if your post works.

If it does then set it back to your postname style and check again.

Please let me know if this helps.

Thanks,
Shane

#482455

Hi Shane,

Saving the permalinks to default -> This solves the problem.
Re-saving the permalinks to my post title style -> The problem re-appears.

#482511

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Jack,

Would you mind providing me with admin access to the website so that I can have a look ?

The private fields will be enabled for your next response.

Thanks,
Shane

#482545

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Jack,

Thank you for the credetnials.

I tested this and everything seems fine. I'm not getting any 404 errors when I create a new post from the form, maybe i'm missing something.

Could you try he forma gain and let me know if you are getting a 404 still.

Thanks,
Shane

#482552

Hi Shane,

Thank you for your response .I can confirm that the new post you made does not give a 404, so that seems good news

But, a new problem with the same CRED form occurs. For some reason the form is not loading at all for a a logged-out user, although the roles in Acces Control are correctly set. It does load in the preview of the CRED admin.

Also it does seem to load in Safari, but not in Chrome.

Because of this, I cant check if it is working now.

Could you check what's going wrong?

Thank you!

#482554

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Screen Shot 2017-01-26 at 3.06.56 PM.png

Hi Jack,

The form actually shows up for me on my account.

Try logging in with the account you provided me with. See Screenshot

As you can see without revealing too much of your site that the form is still there.

Looking forward to hearing from you soon.

Thanks,
Shane

#482558

I checked the form via Safari, because the form does work there (the form does not load in Chrome) and the problem is still there (broken archive, 404 error, parametric search not loading).

Did you check it all the way through the Woocommerce form including the payment (the product is free, so no actual payment needed)?

There is no corresponding order from adding your listing registered in Woocommerce, so that might be the reason you did not detect an error.

#482562

Also (I missed your reply because I was typing my response 🙂 ) - the form is intended for non-users to register their first listing and go through woocommerce for payment and account details. So it should work for guests as well. For me it does not in the Chrome browser when I access the site without being logged in.

#482574

I think I solved the "form not appearing in Chrome issue".

The "form breaking the site issue" is still there.

Try the following sequence:
1. fill in form as a logged-out visitor
2. complete the form and woocommerce (it's free, so you can continue without giving payment details)
3. Woocommerce generates login details and will log you in automatically. Click on the CPT archive (first main-menu button from the left) directly afterwards - the parametric search is broken and so are all the CPT posts.

If I logout and login again, it seems to fix it.

#482800

Hi,

I did some further research and I think I may have found the cause of at least a part of the problem. The post type that is created with the form is connected to a custom user role. I let visitors use the CRED form to create a new post and lead them through Woocommerce for payment / new user creation. Woocommerce creates a new user with the role 'customer'. So, that should be why some functionality is not working for the newly created user. When I change the user role for the created user manually, the problems seem to be solved.

Is there a way to give the newly created user a custom user role with CRED/ Woocommerce?

Something like:

Visitor -> Regular order -> Woocommerce - > Customer created with regular customer role
Visitor -> CRED form #53 -> Woocommerce connected order -> Customer created with custom role

I think that a set-up like this would solve the problems.

#482886

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Jack,

Actually you can charge to create user accounts with CRED by enabling the payment option on the CRED form.

This will charge the users and then create their accounts and assign the appropriate account to the user.

Thanks,
Shane

#482893

But setting user roles is only with a user form, I think?

General registration to the site is free for all users, only placing a listing for a certain user role is being charged.

I use a post form to create a directory listing, using Woocommerce for the payment and let Woocommerce handle the account creation. I do not mind setting it up differently, but I need the listing creation, payment and account creation in one flow.

How could I use a the option to set a custom role while creating a CPT? I do not see the option to add CPT fields to a user form, and vice versa.

#482984

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Jack,

Yes that is true but user forms also have a payment option as well.

But the option of setting a user role using the creation of a CPT can be done using a custom hook for CRED and then changing the user role when the form is submitted.

For eg.

add_action('cred_save_data', 'my_save_data_action',10,2);
function my_save_data_action($post_id, $form_data)
{
    // if a specific form
    if ($form_data['id']==12)
    {
   $current_user = wp_get_current_user();
       $user_arr = array( 'ID' => $current_user->ID, 'role' => 'my new role') 
          wp_update_user( $user_arr);
        
    }
}

This should update the user with the new role after the form is submitted. To test this just replace the 12 with the ID of your form.

Please let me know if this helps.
Thanks,
Shane

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.