I am planning to purchase a plugin that allows users to create polls and then embed them via shortcode into posts. It looks like a great plugin all around; however, the functionality I would like is not quite there. I would prefer it if the plugin would automatically add the post to the front end after the user clicks submit, instead of provide the user with a shortcode.
I would like to modify the code so that the process of creating a poll is as follows (italics is what I would need to implement):
- User customizes his poll, clicks submit
- The shortcode is generated, but the user does not see the shortcode
- Some function creates a new post in WordPress, with the user who created the poll as the author, and the only content in that post is the shortcode that was just generated
Is there an easy way to do this? For context, I am a theme developer; however, I do not have any experience with developing plugins. I know a decent amount of PHP.
Could somebody please provide a generalized example of how I would go about doing this (i.e., getting the shortcode, then creating a post with the shortcode as the post's content)? Would I use
wp_insert_post or something else?
Also, since this is another developer's plugin and I would be modifying the functionality of it, are there any best practices I should follow? For example, instead of overwriting their code, should I create a new plugin whose only purpose is to interact with the polling plugin and create posts out of its shortcodes?