Skip Navigation

[Resolved] Split: I neeed to set a Duplicate Post link on front end (no user access admin pages) – update post slug for duplicated post

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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

This topic contains 10 replies, has 2 voices.

Last updated by Minesh 1 year ago.

Assisted by: Minesh.

Author
Posts
#2660125

Hi Manesh,
There is another element to fix, in order to complete this functionality :
- when duplicating, the permalink/slug of the duplicated Objet is set to : copie-source-objet-name
- then, when updating the Object Title, thre permalink stays the same, and is not updated to the new objet name

Is there a way to update the parmalink/slug of the new Objet on the publication form (without access to the admin dashboard) ?

This is a necessary, indispensable functionality. Thank you for helping me achiev it.
Best regards,

Francesco De Grandi

#2660129

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Updating the post title will not update the post slug. If you update the post title then you should also update the post slug.

Are you trying to update the post title from the backend admin?

#2660139

Hi Minesh,
No, my client does not have access to the backend admin - that is the whole purpose on the user interface I am building, simplified and customized precisely for the client to use :
- therefore I need to be able to update the post slug on the front end post form (the one visible on the screen capture I uploaded above)
- or in any other way on the front end...

Hope that helps.
Best regards,

Francesco

#2660245
Toolset_Object Edit Template_Permalink.JPG

Sorry. Attached here is the screen shot of the Objet Editing Form Template.

By the way, why isn't there, in the custom fields group interface, a field for the post's slug ?
It would resolve the issue...

Best regards,

Francesco

#2660277

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Can you please share problem URL where exactly I can see the form?
- Do you mean I will have to click on the link "modifier base"?

By the way, why isn't there, in the custom fields group interface, a field for the post's slug ?
==>
post slug (post_name) is native WordPress post field and we can not treat as custom field.

#2660295
Toolset_Object Form edit.JPG

Hi Minesh,

To get to the form, click the link "Modifier base" :
- you'll get to the form on the Front end

To get to the editing template containing the form :
hidden link

Regarding a field for the post slug :
- I understand that it is a native field and I reword my question :
- why is there no slug field in the Post Form admin page, in the "Post Elements" list (see attached screen capture)
To get to that Objet Form "Modifier Base Objet Confrérie" :
hidden link

Hope this helps.
Best regards,

Francesco

#2660309

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Can you please share admin access details as the admin access details shared before is not working at this end.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2660323

One more thing :
- the existing staging site "hidden link IS NOT UP TO DATE.
If necessary, I will have to setup a new one.

Francesco

#2660865

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Can you please check now.

I've added the following Toolset form's hook to the "Custom Code" section offered by Toolset to update the post slug when form is saved.
=> hidden link

add_action('cred_save_data', 'func_update_object_post_slug', 10, 2);
function func_update_object_post_slug($post_id, $form_data) {
  
	if ($form_data['id']==18806) {
 
   		$post_title=$_POST['post_title'];
   		$slug = sanitize_title($post_title);
   		wp_update_post(array('ID'=>$post_id,'post_name' => $slug));
	}
}

More info:
- https://toolset.com/documentation/programmer-reference/adding-custom-code/using-toolset-to-add-custom-code/
- https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data

#2661133

Hi Minesh,

Yes, it is working as exspected. Thank you very much. Gosh, I am learning so much...
I had totally forgotten the possibity to set up custom code in Toolset :
- if I want to apply the Duplicate Custom Post functionality/shortcode to another entity, for instance Createur,
- would it be correct to modify the custom code you added in the following way ? :
--- the Createur Form ID is : 18580)
--- if ($form_data['id']==18806 || $form_data['id']==18580) {

$post_title=$_POST['post_title'];
$slug = sanitize_title($post_title);
wp_update_post(array('ID'=>$post_id,'post_name' => $slug));
}
I suppose that the function (in Snippets plugin) and the shortcode [duplicate_post_link] can be used as they : right?

Thank you for answering these 2 questions regarding that Duplication functionality.
Best regards,

Francesco

#2661681

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Yes - that's correct for both the questions you asked.

#2661999

Hi Minesh,

Thank you very much for all your help for this Duplication issue : I learned a lot...
The functionality works very well, and I know now tht I can apply it to other Custom Types and Forms.

Best regards,

Francesco