Skip to main content
1 of 2

I think you are headed down the right path, but I think that func_get_args() is going going to give you the arguments passed to that function.

I took a different approach that I think might work. I found debug_backtrace() to be helpful in debugging Actions and Filters before. And the 4th element in that array it returns you is the do_action call with all the arguments that live inside of the call you are looking to make.

Here is a snippet I put together with a few actions I tested:

<?php

// Here are the Actions I tested against.
$events = array(
    'profile_personal_options',
    'profile_update',
    'show_user_profile',
    'show_user_profile'
);

foreach ($events as $event) {
  add_action($event, function($args = null) {

    $backtrace = debug_backtrace();
            
    // This element is going to be the do_action call
    echo '<pre>';
    print_r($backtrace[3]['function']);
    echo '</pre>';
        
    // The first element of the args is going to be the $event
    array_shift($backtrace[3]['args']);
        
    // Leaving you with the rest of the parameters available to that action
    echo '<pre>';
    print_r($backtrace[3]['args']);
    echo '</pre>';

  }, 100);
}

If this is not what you are looking for, or I am off...let me know and I'd be happy to take my answer down!!