WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am developing custom registration form. Is it possible to get current action (comment adding or user registration) in function? For example i am using:

add_filter('preprocess_comment', 'checkQuestion');
add_filter('registration_errors', 'checkQuestion', 10, 3);

So, from function checkQuestion i need somehow to know from what action it was called?

share|improve this question

You can simply use current_filter() WordPress function.


share|improve this answer

This can be un-reliable because it depends on the values coming in from the registration_errors filter, but hopefully you get the idea.

function checkQuestion($var1, $var2 = '', $var3 = '') {
        if(empty($var2) && empty($var3)) {
            // You are on the preprocess_comment filter because you did not receive a total of three variables
        } else {
            // You are on the registration_errors filter because $var2 and $var3 are not empty
        return $var1;       
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.