What I'm trying to do is similar to this one but we have a bit of difference in getting our info.
Basically, when a user creates a post (under suggestions custom post type) on my site, it is not published right away but is in pending review status. I'm using Gravity forms so user can create posts/suggestions on the frontend. I attached this frontend form on particular pages.
What I want is that upon saving post (pending review) of the user, a category under Suggestions post type will be created depending on the name and slug of the current page where the form is attached. Of course it shouldn't be created again if it's already there (eg. there was another user who first posted suggestion).
For example: The user posted a suggestion on the Actors page (of Movie post type). This page has slug actors. If he is the first to suggest on this page, a category should be created under Suggestions post type with the name Actors and slug actors in which his post (or suggestion) should be saved. If he's not the first to suggest, then there's no need to recreate the category because it was already created before by someone, it just needs to be saved under this category (which can be handled by the Gravity forms so long as the category is existing and not to be created).
I'm not sure of what to put in functions.php. Anyone who can help me with this? I hope I made myself clear here.