Force new users to accept terms AND privacy policy?

Hello! Wondering if there’s a way to have new registrants accept both the terms and conditions AND the privacy policy (check boxes?) Thanks!

To add the terms and conditions checkbox to the registration form please try to set the page for Registration Terms Page setting in HivePress/Settings/Users

To add the privacy policy checkbox to the registration form please try this PHP snippet

add_filter(
	'hivepress/v1/forms/user_register',
	function( $form ) {
		  $form['fields']['custom_message_terms_policy'] = [
			'caption' => 'I agree with <a href="#" target="_blank">privacy policy</a>',
			'type'      => 'checkbox',
			'required' => true,
			'_external' => true,
			'_order'    => 1000,
		];

		return $form;
	},
	1000
);
1 Like

That’s great, but I would like to know where this acceptance data is stored so that I can prove it if I ever have a judicial inspection?
Or in which table can I see that it was recorded?

Please try this PHP snippet instead. Then please try to create a new user and please check table wp_usermeta (or your_database_prefix instead of wp). There should be meta key hp_registration_terms_accepted with value 1 and hp_registration_policy_accepted with value 1

Also please note that users can not register without checking these checkboxes in the registration form

add_filter(
	'hivepress/v1/forms/user_register',
	function( $form ) {
		  $form['fields']['custom_message_terms_policy'] = [
			'caption' => 'I agree with <a href="#" target="_blank">privacy policy</a>',
			'type'      => 'checkbox',
			'required' => true,
			'_external' => true,
			'_order'    => 1000,
		];

		return $form;
	},
	1000
);

add_action(
	'hivepress/v1/models/user/register',
	function( $user_id, $values ) {
		if(isset($values['_terms'])){
			update_user_meta($user_id, 'hp_registration_terms_accepted', true);
		}
		
		if(isset($values['custom_message_terms_policy'])){
			update_user_meta($user_id, 'hp_registration_policy_accepted', true);
		}
	},
	10, 
	2
);
1 Like

Thanks yevhen, I have done it and it is correct. in the usermeta table it saves a registration field with value 1.
The problem is that this record can be modified by the web administrator and is not valid as proof in an inspection.
Isn’t there any way to send the registration by email and it will be a proof that on day x at time x it was registered with value “accepted”?
thank you

Administrators can edit any database values in any case, there’s no way to prevent this. Please try customizing the email text that is sent to the site admin when a new user is registered, e.g. add text about the agreement. It’s valid because if you enable this checkbox, there’s no way a user can register without accepting it, if users don’t check it they can’t proceed.

Ok, how and where can I modify or add that text?

Please try to create the email in HivePress/Emails and choose User Registered as an email event. Then you can override the default user registration email. Also, there are email tokens in Details section which you can use in the email

Thank you very much yevhen I have managed it. But my data protection law advisor suggests me that I should leave 3 obligatory fields in the email sent by hivepress:
1.- day
2.- time
3.- IP from where the user accepted the terms of use.

Is there any way to include html php code to be reflected in the mail.

I think this is very valuable for many people.

thanks

Unfortunately, there’s no temporary code snippet for this, this requires advanced customizations. As the email notification about a new user is sent by WordPress and this email has the date and time when it was sent. So it is needed advanced customization to add IP address data to this email

Ok yevhen.
I will look for a plugin to see if I get something.
Thanks a lot.

I still have my problem with the Data Protection Act. In my country it is also mandatory that the user who fills in and sends comments also accepts a checkbox and saves the acceptance.
I have seen a code that I have downloaded that says it does this but I can’t get it to work, something I am doing wrong.
Would you be so kind to take a look to see if it is not well done. Thank you very much.

/* Privacy check box after the comment form */
add_filter( 'comment_form_field_comment', 'mi_campo_de_privacidad_en_comentarios' );
function mi_campo_de_privacidad_en_comentarios( $comment_field ) {
    return $comment_field.'<label><input type="checkbox" name="privacy" value="privacy-key" class="privacyBox" aria-req="true"> Acepto la <a target="blank" href="https://ayudawp.com/legal/">política de privacidad</a></label>';
}
//validación por javascript
add_action('wp_footer','valdate_privacy_comment_javascript');
function valdate_privacy_comment_javascript(){
    if (is_single() && comments_open()){
        wp_enqueue_script('jquery');
        ?>
        <script type="text/javascript">
        jQuery(document).ready(function($){
            $("#submit").click(function(e)){
                if (!$('.privacyBox').prop('checked')){
                    e.preventDefault();
                    alert('Debes aceptar nuestra política de privacidad marcando la casilla ....');
                    return false;
                }
            }
        });
        </script>
        <?php
    }
}

//sin validación js
add_filter( 'preprocess_comment', 'verify_comment_privacy' );
function verify_comment_meta_data( $commentdata ) {
    if ( ! isset( $_POST['privacy'] ) )
        wp_die( __( 'Error: Debes aceptar nuestra política de privacidad marcando la casilla ....' ) );

    return $commentdata;
}

//guarda el campo como comment meta
add_action( 'comment_post', 'save_comment_privacy' );
function save_comment_meta_data( $comment_id ) {
    add_comment_meta( $comment_id, 'privacy', $_POST[ 'privacy' ] );
}

Sorry, we can’t review third-party code and debug it, this is not exactly related to HivePress functionality. Please consider using the available Terms of Use checkbox, if you linked a page in HivePress/Settings/Listings/Submission then users can register only if they check it, there’s no other way. Depending on legal requirements, you can use the code snippet suggested by Yevhen to save some value in user meta, or customize the WordPress “New User” email (it’s not sent by HivePress) and change it’s text to something like “A new user agreed to the Terms of Use and registered with username…”. I found this related topic IP address in new user notification | WordPress.org
Hope this helps.

Well, you don’t help me because the law of 2022 (at least in my country) requires you to keep the acceptance of terms of use in the database in order to prove that the user accepts the check.

I don’t say it, the law requires it.

And the problem I find is that hivepress is wonderful and very professional, it is true that it is the best, but I need the acceptance to be recorded and that hivepress does not have it or give me a solution.

That is why I ask you to please help me include a piece of php code to include it in Cord snippets because fines for violating data protection law are very expensive. In addition, this that I ask of you, I am sure that many of your customers serve and thank you.

Please just take a look at the previous code and please tell me if it’s right or wrong.

I’m just asking you for that.

Thank you very much, Igor

The code above is not related to HivePress and there’s no easy way to integrate it. I’m sorry for the inconvenience, but customization is beyond our support scope, although as you can see we sometimes provide snippets that solve the issue until it’s fixed or added to the HivePress update.

We provide software with a specific set of features and we guarantee that the features we advertise work as described, but unfortunately we can’t develop custom solutions for your website on demand as part of the fixed-priced theme license, only hired developers can do this.

If features/customizations beyond the available functionality are required you can post a feature request and we can implement it in future updates. If some customization or feature is urgent I recommend hiring a developer via Fiverr or Upwork.

We will consider adding an option for saving the user IP and consent confirmation in future updates, but if it’s urgent please try using the snippet suggested by Yevhen above - it saves a custom value in user meta field when user is registered, so you can customize it further to save the required info (e.g. the IP address and other details required in your country).

Thanks for your understanding.

I understand what you mean.
I’m going to try to solve it following your suggestion of using yevhen’s code above but is there any line of code I can put in that code to send me by mail to the same address always ( for example (name@company.com ) the value of the acceptance?
example “hp_registration_terms_accepted” and “true” , or , “1” , or , “1” , or or , “1” , or “accepted”.
so that it is recorded that a php code collects a value of the registration check and sent by mail to the administrator (in this case the mail (name@company.com).
In this way it can be valid because I am not sending a mail written by me but the mail sends a value captured or collected by the application of the option chosen by the user.
Thank you very much for your attention,

Yes, I recommend using the last code snippet suggested by Yevhen and customizing it if required. For example, you can use this action hook to perform any extra actions when a new user is registered:

add_action(
	'hivepress/v1/models/user/register',
	function( $user_id, $values ) {
		// do something here, e.g. send an email with user IP, save something in the database.
	},
	10, 
	2
);

Thank you, thank you, thank you, that’s what I need.
Thank you very much.
I just need to know the code I need to put in to send an email with the variable ($values[’_terms’]) from the above code.

I THINK I HAVE A FUNCTION THAT IS LIKE THIS BUT I DON’T KNOW HOW TO PUT IT TO WORK.

$to = “destinatario@email.com”;
$subject = “Asunto del email”;
$message = “LAS CONDICIONES HAN SIDO ACEPTADAS”;

mail($to, $subject, $message);

You can try using this one wp_mail() | Function | WordPress Developer Resources Please consider hiring a developer via Fiverr if extra features or customizations are required for your site.