Passing ajax variable to more than one wordpress plugin function

If you want to use a global variable, you have to set it outside any local scope, above your functions. For example:

if (isset($_POST['whatever'])) {
    $variable = $_POST['whatever'];
}

This will store it in the superglobal array. Now, access it using the $_GLOBALS array:

function my_action(){
   $whatever = $GLOBALS['variable'];
}

I would however have an easier approach. You can get the variable in one function and call the other one inside it. Take a look at this:

function first_func(){
    $variable = $_POST['whatever'];
    // Do whatever you want here
    echo "First $variable";
    // Now call the second one
    second_func($variable);
}
function second_func($input){
    echo $input;
}

Avoiding the globals is a good practice since you don’t know what else could interfere with the array.