0

We have a client that has their users agree to a particular terms-of-service agreement when they register for an account.

This is not the standard EE "terms of service" as it's different for the member depending on what member group their are part of.

We had been doing this with a conditional statement and Solspace's User module's register functionality.

Now the client needs to be able to have the members "re-agree" to a different TOS if their member group changes when a site admin changes it in the control panel.

Basically...

"If Jason's member group is not the same as the last time he logged in and is one of these specific member groups, make him have to agree to this new TOS via a modal window (."

Anyone familiar with how to accomplish this or an add-on that can manage that? It doesn't have to be a modal window, but figured that would get the user's attention.

1

Basically, you're going to want to use an extension that hooks this:

member_update_start

https://ellislab.com/expressionengine/user-guide/development/extension_hooks/global/member_model/index.html#member-update-start

A in your extension, do something like this (pseudo code, don't got time to write up a full thing for you):

function check_tos_member_update_start($member_id, $data)
{
    $old_member_gr = ee()->db->select('member_group')
                         ->from('exp_members')
                         ->where('member_id', $member_id)
                         ->get->row_array();

    if ($old_member_gr['member_group'] != $data['member_group'])
    {
        // our user has changed their member group
        // here, you could insert a row into a custom table 
        // that says member_id, and flag a "changed column",
        // and the new group
    }
}

Then, you could write another function in this extension that hooks on to (one of the member_login hooks, just picking this one):

member_member_login_single

https://ellislab.com/expressionengine/user-guide/development/extension_hooks/module/member_auth/index.html#member-member-login-start

that does something like this:

function check_tos_member_member_login_single($hook_data)
{
    $check = ee()->db->select('changed_column')
                     ->from('exp_check_tos') // custom table
                     ->get->row_array();

    // did we submit with a checked TOS?
    if (ee()->input->post('new_TOS))
    {
        // delete my flagged row from exp_check_tos!
    }

    // if not are we flagged for NEEDING one?
    else if ($check['changed_column'] == "true")
    {
        if (!ee()->input->post('new_TOS'))
        {
            // didn't recheck the TOS !!!
            // redirect to login form with TOS flag
            ee()->function->redirect('login-form?tos=1');
        }
    }
}

And then you can use the input class in your login form to see if they are flagged to recheck their TOS (I forget the login form tag so I'm making it up):

{exp:login:form}

    <?php
    if (ee()->input->get('tos'))
    {
    ?> 
        <input type="checkbox" name="new_TOS">
    <?php
    }
    ?>

{/exp:login:form}

Yea, that's kinda a convoluted answer, but I basically thought out your custom addon for you :)

1
  • Wow... this is quite the thoughtful effort and much appreciated! I'll wrap my head around it and see what I can do with it as I'm not a PHP guru but can make my way around. – Jason Turcotte Jul 23 '15 at 15:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.