0

I want to invoke a function before a special action. I want to validate the input of a custom metabox (or custom field) before the changes are saved. If the input value is invalid, then a stop save action with a message should be invoked. If the input fiels is valid, input value should be saved to DB.

add_action('save_change','my_function');
function my_function(){
    if(validate($input){
        //do core action 
    }else{
        //show message and stop action, don't save other field
    }
}

Please advise for me how to implement this problem.

0

For this specific problem you can use Rilwis metabox plugin, where you can define custom metabox along with the validation.

  • thank you. But I don't want use plugin, can you guide me how code to resolve this problem? – user54090 Jun 12 '14 at 7:08

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.