dimanche 19 avril 2015

Multiple AddAction 'init' in shortcodes.php

I'm modifying a wordpress plugin and adding a second form to the shortcode page. Problem is that both forms seem to be processed by the same function. I know the problem might be because I have two 'init' actions but wondering how this could be fixed.



// **********
// first form
// **********

add_shortcode('first-submit', 'cp_first_form');

function cp_first_form($atts, $content = null) {
// html form
}

function cp_first_form_submit_post(){
// code to process first form on submit
}

add_action('init','cp_first_form_submit_post');

// ***********
// second form
// ***********

add_shortcode('second-submit', 'cp_second_form');

function cp_second_form($atts, $content = null) {
// html form
}

function cp_second_form_submit_post(){
// code to process second form on submit
// strangely, it seems both forms get processed by this function after submit.
}

add_action('init','cp_second_form_submit_post');

Aucun commentaire:

Enregistrer un commentaire