Return a custom value in a function added to an action hook

Correct. Action hooks do not return content, and honestly if you need an action hook to return content there is a pretty good chance that you are doing something wrong. However, if it turns out to be your only option the cleanest way to do it is with a static variable:

function action_value_grab() {
  static $value = false;
  $is_hooked = current_filter();
  if (!empty($is_hooked)) {
    $value = true;
  }
  return $value;
}

// var_dump(action_value_grab()); // debug

add_action('test_hook','action_value_grab');
do_action('test_hook');

// var_dump(action_value_grab()); // debug

Just call the function– static_value_grab()— after the hook fires to get the value of $value.

tech