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 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 :)

share|improve this question

1 Answer 1

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. :)

share|improve this answer
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! –  mautematico Jan 6 '13 at 6:59

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.