PriMoThemes — now s2Member® (official notice)

This is now a very OLD forum system. It's in READ-ONLY mode.
All community interaction now occurs at WP Sharks™. See: new forums @ WP Sharks™

Allow membership and ccaps by email domain

s2Member Plugin. A Membership plugin for WordPress®.

Allow membership and ccaps by email domain

Postby earthliz » May 16th, 2011, 12:56 pm

Is it possible for s2Member to automatically grant a user access to specific custom capabilities by email domain?

So for example: We sell levels of membership to companies and universities - and give their employees individual access to the custom capabilities that they've paid for. So, we often receive emails about new employees or ones who don't yet have access to the site, and we have to go in and tweak all their settings. But they all have the same email address (firstname.lastname@company.com) - so it would save a lot of steps if s2member could recognize @company.com and just grant the appropriate access.

Any ideas? Thanks.

Liz
User avatar
earthliz
Registered User
Registered User
 
Posts: 1
Joined: May 16, 2011

Re: Allow membership and ccaps by email domain

Postby Cristián Lávaque » May 16th, 2011, 1:09 pm

This is a great idea, Liz! Thanks!

I'll forward your suggestion to Jason (the Lead Developer of s2Member) to consider it, and maybe suggest how it could be done in the current s2Member. :)
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: Allow membership and ccaps by email domain

Postby Jason Caldwell » May 18th, 2011, 1:29 am

Thanks for a great suggestion.

I'm not sure if we'll be able to address that specific need as a formal feature ( but we'll try ). We DO have plans to improve Custom Capabilities ( work is in progress now, could be another release or two away though ).

In the mean time, you could do something like this.
Create this directory and file:
/wp-content/mu-plugins/s2-hacks.php
Code: Select all
<?php
add_action 
("init", "custom_capabilities_by_domain", 1);
function custom_capabilities_by_domain ()
    {
        if (is_user_logged_in () && current_user_can ("access_s2member_level1") && ($user = wp_get_current_user ()))
            {
                if (stripos ($user->user_email, "@company-a.com") !== false)
                    $user->add_cap ("access_s2member_ccap_company_a");
            }
    }
?>
* This code is untested, but should work fine.
~ Jason Caldwell / Lead Developer
& Zeitgeist Movie Advocate: http://www.zeitgeistmovie.com/

Is the s2Member plugin working for you? Please rate s2Member at WordPress.org.
You'll need a WordPress.org account ( comes in handy ). Then rate s2Member here Image
.
User avatar
Jason Caldwell
Lead Developer
Lead Developer
 
Posts: 4045
Joined: May 3, 2010
Location: Georgia / USA


Return to s2Member Plugin

Who is online

Users browsing this forum: Exabot [Bot], Google [Bot] and 2 guests

cron