I wrote a plugin months ago which added a custom capability when certain members register. Here’s the part business end of the code:
//Look at new registrations...
add_action('user_register', 'check_if_student', 1);
//Check if they qualify as a student or not...
function check_if_student($user_id) {
$user = new WP_User($user_id);
$user_data = get_userdata($user_id);
$user_email = $user_data->user_email;
if (check_email($user_email) ) {
$user->add_cap("access_s2member_ccap_student");
} else { //do nothin!
}
}
//This happens when a user tries to visit a restricted access page...
add_filter('ws_plugin__s2member_sp_access_excluded', 'special_access', 1, 2);
function special_access($excluded, $vars) {
if (current_user_can('access_s2member_ccap_student')) {
$current_user = wp_get_current_user();
$current_user_id = $current_user->ID;
//expired_check returns true if NOT expired yet (still good)
if ( not_expired_check() && not_stop_student_check() ) {
$excluded = TRUE;
return $excluded;
} else {
$excluded = FALSE;
}
}
}
We started getting complaints a couple weeks ago that the plugin is no longer working. (Members with the “student” custom capability no longer are able to access the areas that are restricted by that capability) A lot of things have happened in that time, including the upgrade to WP v3.4 as well as the subsequent s2member update. Any chance this would have an effect on what I’m doing?
-
This topic was modified 4 years, 6 months ago by Brett Adcock.