Issue with Custom Slug Generation After Updating to Version 3.18.6
-
Dear Frontend Admin Support Team,
I’ve been using Frontend Admin to allow users on my website to publish posts directly from the frontend. This functionality has been working seamlessly until recent updates. Specifically, after updating from version 3.18.4 to 3.18.6, I encountered an issue with custom slug generation, which was part of my site’s functionality.
Issue Description:
In version 3.18.4, the custom code I implemented to generate unique slugs for each post based on the user’s username and an identifier from the post worked perfectly. However, after updating to version 3.18.6, this functionality broke, resulting in posts being published with a generic ‘no-name’ slug.Here is a simplified version of the code snippet used for custom slug generation:
// This action hooks into the post saving process to customize the post's slug add_action('frontend_admin/save_post', 'customize_post_slug_frontend_admin', 10, 2); function customize_post_slug_frontend_admin($form, $post_id) { // Check if the post type is the one we're targeting if (get_post_type($post_id) != 'custom_post_type') return; $current_user = wp_get_current_user(); // Generate a slug using the user's username $user_slug = sanitize_title($current_user->user_nicename); // Example identifier from the form data (simplified for this example) $unique_id = 'unique_identifier'; // Combine elements to form a new slug $new_slug = sanitize_title('example-' . $user_slug . '-' . $unique_id); // Update the post with the new title and slug wp_update_post(array('ID' => $post_id, 'post_name' => $new_slug)); }
This code is crucial for maintaining a unique naming convention for posts published via the frontend form by our users. The sudden malfunction after the update has significantly impacted our site’s functionality.
Could you please provide any insights into changes made in version 3.18.6 that might affect my code? Additionally, any guidance on how to adapt my code to restore its functionality with the latest version of Frontend Admin would be greatly appreciated.
Thank you for your time and assistance. Looking forward to your prompt response.
Best regards,
- The topic ‘Issue with Custom Slug Generation After Updating to Version 3.18.6’ is closed to new replies.