Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_filter('comment_form_defaults', 'change_comment_form_defaults');
- function change_comment_form_defaults( $default ) {
- if( isset( $_COOKIE['zgoda'] ) ) { return $default; } //ciacho jest, kolejnej zgody nie potrzeba
- ///a jak ciacha brak, to dopisujemy zgodę do formularza
- $default['fields']['url'] .= '<p class="comment-form-zgoda">' .
- '<label for="zgoda">Bla bla bla</label>
- <span class="required">No to co, zgoda? *</span>
- <input id="zgoda" name="zgoda" value="1" type="checkbox"></p>';
- return $default;
- }
- add_filter( 'preprocess_comment', 'verify_comment_data' );
- function verify_comment_data( $commentdata ) {
- if ( isset( $_POST['zgoda'] ) && $_POST['zgoda'] == 1 ) { //zgoda zaznaczona, stawiamy ciacho
- setcookie('zgoda', 1, 1 * YEAR_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN);
- }
- return $commentdata;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement