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 want to know what is the object for WP_Error Class located in wp-includes/class-wp-error.php because i used a custom registration form plugin in there for validation i used this below function

 function custom_validation($errors) {

            if (($_POST['birthday']) != 1)
                $errors->add('birthday', "<strong>ERROR</strong>:" . please finish birthday);

      return $errors;
    }

add_filter('registration_errors', array('customregistration', 'custom_validation'), 10, 3);

Above function works fine with WordPress default themes(twentytwelve,twentyeleven). but if i use with other themes on registration it shows Call to a member function add() on a non-object

So i searched for $errors object in WP_Error Class but i couldn't able to see a new keyword which is used to create an object for a class.

Now

  1. what is the object for WP_Error Class?
  2. if it is $errors then why am i facing a fatal error called Call to a member function add() on a non-object?
  3. i can't able to see a class instance in WP_Error by using new keyword.
  4. if it not $errors how this is working in default theme?

Note:Other theme registration page looks different from default registration page.

share|improve this question
    
Where are you calling custom_validation(), is hooked onto something? –  Stephen Harris Aug 22 '13 at 12:47
    
registration_errors @Stephen Harris –  sun Aug 22 '13 at 12:49
2  
the phrase "what is the object for WP_Error class" makes no sense, it is equivilant to "what is the object for an object"? which doesn't make sense either. Perhaps you need to find out where custom_validation is being called from, is it a hook or a filter? –  Tom J Nowell Aug 22 '13 at 12:50
    
I am usind Filter registration_errors.... can you please refer the instance of WP-Error class @Tom J Nowell –  sun Aug 22 '13 at 12:54
    
@raj, see wordpress.stackexchange.com/questions/111130/… - I think my answer there is what you're after. –  Stephen Harris Aug 22 '13 at 12:55
show 14 more comments

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.