0

I have a Wordpress + Buddypress site.

I've created two custom fields which must be filled in each post. Also, I have a form in a custom metabox to show them.

I'm using WyPiekacz plugin to check for minimun words, tags, and categories. So it would be nice if I can tweak it a litle to check if these custom fields were filled or not, and set the post status to draft if the custom fields were empty.

Thanks :)

1 Answer 1

3

I have no experience with this plugin. But when I look at the source, I think something like this should do it:

add_filter( 'wypiekacz_check_post', 'wpse_78395check' );

function wpse_78395check( $errors )
{
    if ( empty ( $_POST['custom_field_name'] ) )
        $errors[] = array (
            'unique_error_key',
            __( 'Custom error message', 'your_textdomain' )
        );

    return $errors;
}

Replace all strings in this example with something useful. :)

1
  • 1
    :D I just did a litle change to your answer, and now it works: add_filter( 'wypiekacz_check_post', 'creepy_fuentecheck' ); function creepy_fuentecheck( $errors ) { global $post; $mustFill = ''; $mustFill = get_post_meta($post->ID, 'custom_field_name', true); if ( empty ( $mustFill ) ) $errors[] = array ( 'fuente_vacia', __( 'Por favor, agrega la fuente', 'wypiekacz' ) ); return $errors; } Thanks! Commented Jan 6, 2013 at 6:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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