latest stable versions: v150827 (changelog)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Agree to Terms with current account upgrading

Home Forums Community Forum Agree to Terms with current account upgrading

This topic contains 6 replies, has 2 voices. Last updated by  Cristián Lávaque 3 years, 3 months ago.

Topic Author Topic
Posted: Friday Sep 20th, 2013 at 2:11 pm #59727
Username: rmendoza

I have used the profile fields to setup a terms of service with new registered customers. It works great! Thanks for that. I have a problem with enforcing the terms on updates. We just updated our site to include protected content that we only give access to with a paid membership. We had 8,000 previous users that have NOT accepted the new terms. Is there a way that we can require the current users to agree to the terms when they upgrade (if they decide to)? This is a necessity! Thanks in advance.

List Of Topic Replies

Viewing 6 replies - 1 through 6 (of 6 total)
Author Replies
Author Replies
Posted: Monday Sep 23rd, 2013 at 5:47 pm #59781
Username: rmendoza

I need this to be handled immediately please. I would appreciate any and all help. Please help asap.

Posted: Wednesday Sep 25th, 2013 at 6:12 am #59844

You could probably have a conditional that checks if the user agreed to the terms and if not, ask him to do it showing him a profile form.

[hilite path]Dashboard -› s2Member® -› API / Scripting -› Advanced PHP Conditionals[/hilite]
[hilite path]Dashboard -› s2Member® -› API / Scripting -› Member Profile Modifications[/hilite]

You could probably have this in a must-use plugin that will always redirect him to a page that has this message when he’s logged in until he agrees. Knowledge Base » Hacking s2Member Via Hooks/Filters

The wp_loaded hook may be a good one to use.

I hope that helps!


Posted: Friday Sep 27th, 2013 at 4:21 pm #59966
Username: rmendoza

Thanks for the help.

I am having a new problem. I am unable to edit the field using s2member. Here is what I have:

function tos_agreement_check( $obj ) {
    if( is_user_not_logged_in() )
    $agreed_to_tos = get_user_field( 'tos' );
    if( $agreed_to_tos )
    if( $obj->request != 'my-account' ) {
        wp_redirect( home_url( '/my-account' ) );                                                                                                                                                                                                                              
add_action( 'wp', 'tos_agreement_check' );

And to display the field:

<form method="post" name="accept_tos" id="accept_tos" action="<?php echo esc_attr (site_url ("/")); ?>">
<?php echo c_ws_plugin__s2member_custom_reg_fields::custom_field_gen (true, $custom_fields['tos']['config'], 'ws_plugin__s2member_profile_', 'ws-plugin--s2member-profile-', 'ws-plugin--s2member-profile-field', '', 1, '', $custom_fields, $agreed_to_tos, '');?>
<input type="hidden" name="ws_plugin__s2member_profile_save" id="ws-plugin--s2member-profile-save" value="<?php echo esc_attr (wp_create_nonce ("ws-plugin--s2member-profile-save")); ?>" />

I can get to the point of it alerting me that the profile has been saved, but it hasn’t. I figured out that the reason is because I have it noteditable after registration. Is there anyway to bypass this. I have not found a way to do this without setting the field to editable. I only want it editable on registration and at this certain place.

Thanks in advance,

Posted: Monday Sep 30th, 2013 at 2:35 pm #60010
Username: rmendoza

was a double post … see below

  • This reply was modified 3 years, 3 months ago by  RM.
Posted: Monday Sep 30th, 2013 at 2:39 pm #60012
Username: rmendoza

I got it to work with a few hooks. I am posting the code below for anyone who would like to use it. I am posting this as well for the moderators/programmers to see if there is an easier way to do this.

in s2hacks.php (in mu-plugins)

function save_tos_profile_modifications( $defined ) {
    if( !$defined['fields_applicable'] || !in_array( 'tos', $defined['fields_applicable'] ) )
    if( isset( $defined['_p']['ws_plugin__s2member_profile_tos'] ) ) {
        global $current_user;
        if( isset( $defined['fields'] ) )
            $fields = $defined['fields'];
            $fields = array();
        $fields['tos'] = $defined['_p']['ws_plugin__s2member_profile_tos'];
        update_user_option ($current_user->id, 's2member_custom_fields', $fields);
add_filter( 'ws_plugin__s2member_during_handle_profile_modifications', 'save_tos_profile_modifications', 10, 1);
function configure_tos_editable( $configured, $defined) {
    if( isset( $defined['field'] ) )
        if( $defined['field']['id'] == 'tos' )
            array_push( $configured, 'tos' );
    return $configured;
add_filter( 'ws_plugin__s2member_custom_fields_configured_at_level', 'configure_tos_editable', 10, 2 );

The first function will save the tos to the member profile. Just because you sent the new value of tos didn’t make the function save it. This will make the function always save it if it is present. The second function will allow the field to be visible. Before, it will block the showing of the field due to my current setup of not editable and hidden after registration.

I also used the code previously posted. Hope this helps someone.

Posted: Tuesday Oct 1st, 2013 at 6:24 am #60047

Thanks for sharing it. :)

Viewing 6 replies - 1 through 6 (of 6 total)

This topic is closed to new replies. Topics with no replies for 2 weeks are closed automatically.

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.