Skip Navigation

[Resuelto] URGENT – Cred Auto Draft URLs Generated by Form are no longer unique…

This support ticket is created hace 2 años, 6 meses. 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.

Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.

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: Asia/Hong_Kong (GMT+08:00)

Este tema contiene 11 respuestas, tiene 2 mensajes.

Última actualización por shawnW-3 hace 2 años, 5 meses.

Asistido por: Luo Yang.

Autor
Mensajes
#2377489

I am trying to:
We use a form for our customers to create custom posts of a particular CPT. We've always used the default Toolset generated URL for these posts because it's unique and doesn't require anything of the user submitting it.

Seemingly out of nowhere today the URLs stopped being unique.
Every post created with the form has a URL ending in cred-auto-draft-c8753e0c5d38195974c3942235a490d3

...so for instance the last three posts created are all linked to:
website.com/cpt/cred-auto-draft-c8753e0c5d38195974c3942235a490d3
website.com/cpt/cred-auto-draft-c8753e0c5d38195974c3942235a490d3
website.com/cpt/cred-auto-draft-c8753e0c5d38195974c3942235a490d3

Link to a page where the issue can be seen:

This is a stripped down version of the same form. No JS...

You can fill out the form and you will be redirected to a url ending in cred-auto-draft-c8753e0c5d38195974c3942235a490d3
You can fill it out again and will again be redirected to the same cred-auto-draft-c8753e0c5d38195974c3942235a490d3 url

enlace oculto

On the backend of the site, if you click the view link under each post you will be taken to this same URL everytime. The information in the post will be unique, but the URL will not be.

I expected to see:
A unique URL

Instead, I got:
website.com/cpt/cred-auto-draft-c8753e0c5d38195974c3942235a490d3

A few things to NOTE
1) This is happening on four instances of the same site: Live, staging, test, dev...
all of these sites have varying degrees of plugin/theme/wp versions. The version I'm sharing is the most up-to-date in every regard.

2) We will look into changing the permalink structure following this so we're not relying on Toolset Forms to generate unique URLs, however, we want to be very sure this isn't a larger problem with greater implications.

3) I have a php script that I've been using for over a year without issue that renames posts using Toolset Custom Field data. This is included in Toolset Custom Code under settings and has not been showing any errors. Again, it's been in use for quite sometime.

However, on the dev site I turned it off and started getting different results with the URLs (-1, -2, -3 appended)...
website.com/cpt/cred-auto-draft-c8753e0c5d38195974c3942235a490d3-1
website.com/cpt/cred-auto-draft-c8753e0c5d38195974c3942235a490d3-2
website.com/cpt/cred-auto-draft-c8753e0c5d38195974c3942235a490d3-3

For the test instance of the site, I have left this on. Here is the code...

<?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.

add_action("cred_save_data", "customsub_save_data_action",10,2);
function customsub_save_data_action($post_id, $form_data)
{   
    // if a specific form
    if ($form_data["id"]==435)
    {
           $subseries = $_POST["wpcf-mainsub-series-opt"]; 
            // Update the post into the database
		   $name = $subseries ."-". $post_id;
		   $customsub_post = array(
                'ID'           => $post_id,
                'post_title' => $name,
				'post_name' => $name
            );
            wp_update_post( $customsub_post ); 
	}
	
	if ($form_data["id"]==436)
    {
           $subseries = $_POST["wpcf-mainsub-series-opt"]; 
            // Update the post into the database
		   $name = $subseries ."-". $post_id;
		   $customsub_post = array(
                'ID'           => $post_id,
                'post_title' => $name,
				'post_name' => $name
            );
            wp_update_post( $customsub_post ); 
	}
}
#2378593

Hello,

It is a custom codes issue, please provide your test site credentials in below private message box, also point out where I can edit your custom PHP codes, I need to test and debug it in a live website, thanks

#2379347

I can see the problem in your website, two problems:
1) Your custom codes is using field slug "wpcf-mainsub-series-opt", but there isn't such a field in the post form "Create New Custom Subwoofer":
enlace oculto
I assume you are going to use user name field "wpcf-user-name-sub-customizer" as post title, so I have change the custom PHP codes line 16, from:

           $subseries = $_POST["wpcf-mainsub-series-opt"]; 

To:

           $subseries = $_POST["wpcf-user-name-sub-customizer"]; 

2) After above change it still won't work as expected, it produce below URLs:
website.com/cpt/cred-auto-draft-c8753e0c5d38195974c3942235a490d3-1
...
Which is a problem of another plugin: Permalink Manager Lite
After deactivate that plugin, it works fine, can you confirm it?

#2379583

That seemed to fix the issue. It's very strange that it started happening more than two weeks after the last permalink manager update AND that it only happened with this form for this CPT, especially considering I don't have any custom permalink manager settings running for this CPT.

In any case, I'll get with their support on resolving it.

Thank you

#2379633
new-urls.PNG

No, I'm sorry, I didn't do enough testing...

With Permalink Manager off, the PHP Script does work to change the name and the URL
But with the Permalink Manager OFF -AND- the PHP Script Off, I get the same result.

Of course, I want to automatically rename these subs, but permalink manager does not appear the problem in this case, AND I do still need permalink manager for a number of other custom post type permalinks.

#2379643

Access is still granted with the same account. Please test again using the same links and credentials to confirm my findings.

#2380035

I have tried again in your website, by these steps:
1) Deactivate custom codes "renamecustomsubs"
Deactivate plugin "Permalink Manager Lite"
2) Test the post form in front-end:
enlace oculto
fill and submit the post form, I get below URL:
enlace oculto
fill and submit the post form with same data, I get below URL:
enlace oculto
Both of them are unique URLs

Is there any missing steps?
Where and how can I produce the same problem you mentioned above:
https://toolset.com/wp-content/uploads/2022/06/2379633-new_urls.png

Can you provide detail steps to reproduce the same problem?

#2380289

So you're saying that's working the way Cred Auto Drafts are designed to to work? That the auto generated name is not supposed to be entirely unique and that instead there is supposed to be an appended digit at the end of every URL?

That when working correctly, a Cred Forms auto generated permalink should look like this...
cred-auto-draft-10f9c462895c049086f7267dde0c3cb7-1
cred-auto-draft-10f9c462895c049086f7267dde0c3cb7-2
cred-auto-draft-10f9c462895c049086f7267dde0c3cb7-3
cred-auto-draft-10f9c462895c049086f7267dde0c3cb7-4

and not like this...
cred-auto-draft-38eeed26fe313417c3fc674b067fb8b4
cred-auto-draft-25c1b90c6c695976cb8ab742d1916ed3
cred-auto-draft-ae4c1b186bc8b2fc28a29a7943a34a57
cred-auto-draft-0d0682325d33ab140433ce4e61f57de6

That doesn't seem right. It still seems to be a bug in Toolset which has caused the unique title generator to stop generating unique titles, because nothing in permalink would have ever generated this complex cred-auto-draft, and if memory serves, this was how it worked prior to Permalink Manager's install/activation.

Even though we could probably code a workaround, we would like to find the source of this issue.

#2380895

First, those URLs you mentioned above:
cred-auto-draft-10f9c462895c049086f7267dde0c3cb7-1
cred-auto-draft-10f9c462895c049086f7267dde0c3cb7-2
cred-auto-draft-10f9c462895c049086f7267dde0c3cb7-3
cred-auto-draft-10f9c462895c049086f7267dde0c3cb7-4
They are unique URLs, and it is conducted when you did not setup the post title, and there are not any meaning in the string 10f9c462895c049086f7267dde0c3cb7-1, it is generated automatically.

As I mentioned above, your website issue is a problem of "Permalink Manager Lite" plugin, it does not respect WordPress post permalink, you need to contact them for it.

#2381445

We'd like to request that this ticket be transferred to a supporter that's closer to our timezone. It's nothing personal, but we're averaging one reply a day and after a week, we'd like to improve the pace of this discussion.

"They are unique URLs"
Yes, and this is the main issue, but to get to the root of this problem, we need to figure out why the only difference in each string is the appendix, and that should get to why this one post type in Toolset has this conflict where other post types (custom and WP native) managed by Permalink Manager Lite don't have any issues.

Every URL created for this post type starts with...
cred-auto-draft-10f9c462895c049086f7267dde0c3cb7
...You don't think that's a little strange?

You don't see a difference in this automatically generated URL from the "Custom Sub" post type which we were originally having problems with...
cred-auto-draft-10f9c462895c049086f7267dde0c3cb7-1
cred-auto-draft-10f9c462895c049086f7267dde0c3cb7-2

...and this automatically generated URL from a different post type we haven't had problems with...
cred-auto-draft-38eeed26fe313417c3fc674b067fb8b4
cred-auto-draft-25c1b90c6c695976cb8ab742d1916ed3
...?

HOW?

Let's recap...

The original issue was the "Custom Sub" post type was generating entirely identical URLs.
cred-auto-draft-10f9c462895c049086f7267dde0c3cb7
cred-auto-draft-10f9c462895c049086f7267dde0c3cb7

Other post types using the automated URL were generating VERY unique URLs.
cred-auto-draft-38eeed26fe313417c3fc674b067fb8b4
cred-auto-draft-25c1b90c6c695976cb8ab742d1916ed3

So the problem was isolated to the "Custom Sub" post type.

Next, you turned off Permalink Manager Lite.

Now the "Custom Sub" post type is generating URLs that are BARELY unique URLs - just appended with a dash and a digit.
cred-auto-draft-10f9c462895c049086f7267dde0c3cb7-1
cred-auto-draft-10f9c462895c049086f7267dde0c3cb7-2

While other post types using the automated URL continue to generate VERY unique URLs.
cred-auto-draft-38eeed26fe313417c3fc674b067fb8b4
cred-auto-draft-25c1b90c6c695976cb8ab742d1916ed3

I'll accept that there is a conflict with Permalink Manager Lite, but the Custom Sub post type URLs clearly are not being generated properly, even with Permalink Manager Lite TURNED OFF, and that's the issue that needs to be addressed and ruled out before I move on to seeking Permalink Manager support.

If the "Custom Sub" post type was generating entirely unique URLs, like...
cred-auto-draft-38eeed26fe313417c3fc674b067fb8b4
cred-auto-draft-25c1b90c6c695976cb8ab742d1916ed3
...then I would have already moved on, because that's clearly functioning properly.

BUT THIS...
cred-auto-draft-10f9c462895c049086f7267dde0c3cb7-1
cred-auto-draft-10f9c462895c049086f7267dde0c3cb7-2
...is strikingly odd behavior compared to other post type URLs generated with Cred Forms.

#2381759

Toolset Forms plugin is using below PHP codes to generate post title when post title field is empty:

return 'CRED Auto Draft ' . md5( $this->get_ip() );

You can find it in the plugin file \plugins\cred-frontend-editor\application\models\wordpress\auto-draft.php, line 105

So it will generate different post title when you use different IP address.

There isn't anything we can do here, you need to check the plugin author "Permalink Manager Lite" for the permalink issue.

#2385639

My issue is resolved now. Thank you!

Please see...
https://toolset.com/forums/topic/error-code-thrown-on-form-submit/
...for possible resolution.

Waqar seems to have solved this issue, but it's unclear how it was solved. In any case, this post type is now generating unique urls WITH Permalink Manager Lite set to active which didn't require plugin specific support or changes.