BuddyDev

Search

Terms and Conditions on registration page

  • Participant
    Level: Initiated
    Posts: 2
    Gert on #10955

    Hi

    How can I get a checkbox for terms and conditions on register page?

    – with Xprofile fields the users can change it on their profile page and it looks a bit clumsy
    – are there any plugins that register that on the db? I have seen a plugin with javascript that just blocks the submit button

    What is the verification and db registration procedure?
    Thanks

  • Keymaster
    (BuddyDev Team)
    Posts: 24149
    Brajesh Singh on #10969

    Hi Gert,
    Welcome to the forum.

    I see 2 plugins listed at the moment:-
    https://wordpress.org/plugins/simple-terms-and-conditions-for-buddypress/
    https://wordpress.org/plugins/agreeable/

    There were others too (xprofile terms field etc) but does not seem to be available now.

    – Using xprofile allows the site admins to do the things without any extra step(setting page etc). Infact, I have done one such field for a client of mine earlier and I will extract and post on github in 1-2 day. You can easily hide the terms field on user edit profile(Using my Non editable profile field for example).

    Or do you want it in the user meta for some specific processing? I will be willing to know and will be glad to assist.

    Thank you
    Brajesh

  • Participant
    Level: Initiated
    Posts: 2
    Gert on #11070

    Thanks for the suggestions Brajesh

    I’ve added a checkbox on the register page and added code below to register it in db. (Also modified Ajax to have the field as required)

    add_action( 'user_register', 'tos_registration_save', 10, 1 );
    function tos_registration_save( $user_id ) {
        if ( isset( $_POST['terms_of_service'] ) ){
            $terms_of_service = filter_input(INPUT_GET, 'terms_of_service', FILTER_VALIDATE_BOOLEAN );
                update_user_meta($user_id, 'terms_of_service', $_POST['terms_of_service']);
        }
    }
    add_action( 'show_user_profile', 'show_terms_field' );
    add_action( 'edit_user_profile', 'show_terms_field' );
    function show_terms_field( $user ) { ?>
    	<table class="form-table">
    
    		<tr>
    			<th><label for="terms">Terms of service & privacy policy:</label></th>
    
    			<td>
                                <span><?php echo esc_attr(get_the_author_meta( 'terms_of_service', $user->ID )) ? 'Agreed' : '' ; ?></span>
    			</td>
    		</tr>
    
    	</table>
    <?php }

    However, over time tos may change so I would need to ask registered members to agree to the new tos if they want to continue using the site or just have a banner that they can click away to notify them. Building further on this seems a messy way to me.

    Any suggestions?

  • Keymaster
    (BuddyDev Team)
    Posts: 24149
    Brajesh Singh on #11112

    Hi Gert,
    Thank you.

    I am glad you have solved it.

    The simplest solution will be to store a version number instead of boolean(0,1).

    If you store a number say 1,2,3,4 etc for each version, you can check who have agreed to which version and not.

    Also, It should be transparent from the user. User just needs to see the checkbox but you can use the version number in update code like this

    
    
     $version = 1;// for now.
     update_user_meta($user_id, 'terms_of_service', $version)
    
    

    Hope that helps.

    Regards
    Brajesh

You must be logged in to reply to this topic.

This topic is: not resolved