2

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?

4

You can simply use current_filter() WordPress function.

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

0

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;       
    }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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