Need data from two different actions

Try $globalres=””; add_action(‘quiz_completed’, ‘mi_ld_quiz_ert’, 10, 2); function mi_ld_quiz_ert( $quizdata, $current_user ) { global $globalres; if($globalres== 0){ do_action(‘ld_update_group_access’, $current_user, 2, $remove = false )); } else{ do_action(‘ld_update_group_access’, $current_user, 14, $remove = false )); } } add_action(‘learndash_ques_single_answer_correct’, ‘my_ld_quiz_resp’,5,5); function my_ld_quiz_resp( $answerIndex, $correctAnswer, $userResponse) { global $globalres; $globalres = $answerIndex; }

using globals from wp_link_pages function

I think I figured it out. Most of WordPress is based on global variables. Even the main loop is pulling a giant global variable. So I guess it’s ok since I’m not modifying the actual values here – just pulling it out. It might not be a bad idea to throw $numpages and $page into … Read more

Creating a (global)-mapping

I figured it out myself. function generate_the_excluded_array() { global $excluded_pages; $excluded_pages = array(‘Foo’, ‘Bar’); } add_action( ‘after_setup_theme’, ‘generate_the_excluded_array’ ); And then it can be ‘imported’ using the global, as such: function example_shortcode_definition() { global $excluded_pages; echo $excluded[0]; } add_shortcode( ‘example_shortcode’, ‘example_shortcode_definition’ );

$GLOBALS[‘value1’] is not working

The correct syntax for using with global keyword. To access a global variable in WordPress, you first need to globalize the variable with global $variable; Write inside function.php as: function myfunction(){ global $get_variable; $get_value = $db->query(“SELECT * FROM mytable”)->fetch(); $get_variable = $get_value; } add_action( ‘after_theme_setup’, ‘myfunction’ ); Inside the function you can now able to … Read more