I have a shortcode. With this one, i get the ID (number) of a formular $num_formular. Then, with this one, i had to send all the data in the database.
When I run the following code, it works:
function ss_get_appbenutzer($atts, $content = null){
//global $num_formular;
/* Récupération du numéro du formulaire*/
$atts = shortcode_atts(
array(
'num_formular' => 'NUM_formular'
), $atts);
$num_formular = $atts['num_formular'];
echo 'NUM Formulaire DANS SHORTCODE ='.$num_formular;
}
add_shortcode( 'app-benutzer' , 'ss_get_appbenutzer' );
add_action('gform_after_submission_192', 'msk_gform_process_user_registration_192', 10, 2);
function msk_gform_process_user_registration_192 ($entry, $form) {
echo 'PASSAGE DANS FONCTION msk_gform_process_user_registration_MB --> ok ';
}};
and it prints :
NUM Formulaire DANS SHORTCODE =192 PASSAGE DANS FNCTION msk_gform_process_user_registration_MB --> ok
So it works and the data are in the database.
BUT, i get the number of the formular because it will be various number of formular.
So, i need to have $num_formular as a variable. Then I must use call add_action like this :
function ss_get_appbenutzer($atts, $content = null){
//global $num_formular;
/* Récupération du numéro du formulaire*/
$atts = shortcode_atts(
array(
'num_formular' => 'NUM_formular'
), $atts);
$num_formular = $atts['num_formular'];
echo 'NUM Formulaire DANS SHORTCODE ='.$num_formular;
}
add_shortcode( 'app-benutzer' , 'ss_get_appbenutzer' );
$gform = "'gform_after_submission_".$num_formular."'";
add_action($gform, 'msk_gform_process_user_registration_MB', 10, 2);
function msk_gform_process_user_registration_MB ($entry, $form) {
echo 'PASSAGE DANS FONCTION msk_gform_process_user_registration_MB --> ok ';
}};
But the $num_formular is unknown outside the funtion ss_get_appbenutzer. I tried to use global, but i didn't find something working. And i realized that global is not really a good solution.
Then, i tried to include add_action inside the ss_get_appbenutzer function, like this (i took the code which was working)
function ss_get_appbenutzer($atts, $content = null){
//global $num_formular;
/* Récupération du numéro du formulaire*/
$atts = shortcode_atts(
array(
'num_formular' => 'NUM_formular'
), $atts);
$num_formular = $atts['num_formular'];
echo 'NUM Formulaire DANS SHORTCODE ='.$num_formular;
add_action('gform_after_submission_192', 'msk_gform_process_user_registration_192', 10, 2);
}
add_shortcode( 'app-benutzer' , 'ss_get_appbenutzer' );
function msk_gform_process_user_registration_192 ($entry, $form) {
echo 'PASSAGE DANS FONCTION msk_gform_process_user_registration_MB --> ok ';
}};
but it prints only NUM Formulaire DANS SHORTCODE =192
That means that the add_action, placed here in the ss_get_appbenutzer function, doesn't work (or is not called).
COuld you please give me some hint to make this add_action working?
I am really really stuckked and i tried so many things that i don't know where to search now.
Many thanks for your help
Timama
gform_after_submission_192has presumably already run by the time the shortcode is printed. Honestly, what you're trying to do doesn't make a lot of sense. Why are you using a shortcode for this> It looks like you want to do something after a Gravity Form is submitted, but why would you use a shortcode to do that? Can you explain in more detail what you're actually trying to accomplish.gform_after_submission, that runs for every form. Can't you just use that? And what is theapp-benutzershortcode for? You've described what the Gravity Forms shortcode is for, but not this one. I don't know why you need this shortcode at all, when you can just useadd_action()in your functions file outside of a shortcode.