Thanks for your reply Joy. I’ve been trying to use the callback to trigger the post creation but with no success so far.
Basically what I have been doing is to create a custom-page template where I inserted the do_shortcode
funtion to display the wp-dropzone form. The form works, and I’m able to upload files to the media library. The code looks like this:
add_action('genesis_before_entry_content', 'dropit');
function dropit()
{
echo do_shortcode('[wp-dropzone callback="success: function(file, response){
console.log(response) }" desc="Drop your images here"]');
}
You can see the callback has a success event. So, on success it executes what’s inside. The content now function(file, response){ console.log(response) }
is simply the example from the plugin instructions page. I’m not sure what I should replace it with so it triggers function to create a blog post.
The function to create a blog post looks like this. It currently resides inside my custom page template, but I’m not sure if this is the good location, maybe functions.php would be a better location?
add_action( 'wp_ajax_fotoblog', 'fotoblog' );
function fotoblog()
{
$post = array(
'post_title' => 'My Title',
'post_content' => 'My Content',
'post_status' => 'publish',
'post_type' => 'post'
);
wp_insert_post($post);
wp_die();
}
What I’m failing to grasp is the relationsship between the callback and the function to create a blog post. Of what I have been reading so far, I think I should create a javascript function that triggers the wp_ajax hook so it fires the post creation, but I might be wrong in my understanding of that?