Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

2 Answers 2

You can simply use current_filter() WordPress function.

http://codex.wordpress.org/Function_Reference/current_filter

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
2  
Already found codex.wordpress.org/Function_Reference/current_filter –  user1692333 Feb 18 '13 at 19:02

Your Answer

 
discard

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.