Documentation > Developers > Filter Examples > Enable Mark & Comment by Default

Enable Mark & Comment by Default

The following snippet will activate the “Mark & Comment” collection option by default.

/**
 * Enable mark & comment option by default.
 */
function my_picu_mark_comment_by_default( $metadata, $object_id, $meta_key ) {
    // First, check if we are editing a collection
    if ( function_exists( 'get_current_screen' ) ) {
        $current_screen = get_current_screen();

        // Return true for the `_picu_collection_mark_comment` meta key
        if ( $meta_key == '_picu_collection_mark_comment' && $current_screen->id == 'picu_collection' ) {
            return true;
        }
    }

    return $metadata;
}

add_filter( 'get_post_metadata', 'my_picu_mark_comment_by_default', 10, 3 );Code language: PHP (php)

Please note that this is a bit of a hack, with the caveat, that when the collection edit screen is loaded, the checkbox for the Mark & Comment option will always be checked. If you want to disable the Mark & Comment option for a particular collection, you need to make sure the box is unchecked, right before you publish/send the collection.

Need help?

If you couldn’t find what you were looking for and need more assistance, please get in touch with us directly and we’re happy to help.