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.

What's a good plug-in that taps into the update post or save post action that allows admins to enforce rules such as if a user selects a category with the ID 5 then he also has to select at least one category from the the XYZ custom taxonomy etc - or that update/save won't go thru.

I'd like to write my own rules as to who ( which roles ) can do what and so on.

My plan is this. Get a well-written plug-in and use that as the boiler plate for customizations. So, I can just go into the source code of that plug in and inject all kinds of business logic that is specific to my web site.

Any leads towards this goal is really appreciated.

share|improve this question

closed as off-topic by Pieter Goosen, G. M., Johannes Pille, cybmeta, birgire Nov 23 at 12:15

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

2 Answers 2

I don't know of any plugins that do this, and I'm not sure you'll find one. The closest I can find is the "Mandatory Field" plugin. The specific tasks that you might want are so varied, that I wonder whether a non-bloated plugin that let you customize the validation is out there.

With that said, you'll want to look into the save_post hook. There are quite a few questions about that hook on this very site (such as this one). If you're looking for a code-snippet to modify, I'd start by looking through those questions.

Also, even if you do manage to write a good validation plugin with the save_post hook (btw, I'd use the term "validation" in your future questions and queries as that's really what you're trying to accomplish), I'd consider augmenting it with some client-side jQuery validation. I'd imagine it would be very annoying to have the "Publish" or "Update" button not take the expected action since this is a relatively rare feature to add to a WordPress site. By creating some live validation (backed up by the server-side stuff) would be a much better user experience.

share|improve this answer
    
mrwweb, congratulations on your 2k, cool! –  brasofilo Jun 1 '12 at 2:15
    
Thanks @brasofilo! –  mrwweb Jun 1 '12 at 2:49

I know that Advanced Custom Fields does that.
I keep citing it, but I promise I'm not affiliated...

enter image description here From a fast analysis, this is the code that does it, but couldn't track how it's being hooked...

$('form#post').live("submit", function(){
    do_validation();

    if(acf.valdation == false)
    {
        // reset validation for next time
        acf.valdation = true;

        // show message
        $(this).siblings('#message').remove();
        $(this).before('<div id="message" class="error"><p>' + acf.validation_message + '</p></div>');

        // hide ajax stuff on submit button
        $('#publish').removeClass('button-primary-disabled');
        $('#ajax-loading').attr('style','');

        return false;
    }

    $('.acf_postbox:hidden').remove();

    // submit the form
    return true;        
});
share|improve this answer

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