[wp-edu] User access management
Chuck Scott
chuck at avantigroup.com
Wed Jan 8 17:17:04 UTC 2014
Hi David - i've recently been working on a Multisite Network and found
a neat way to control user levels with a mix of using PODS to extend
user tables, custom child theme template files as well as actions and
filter hooks thus share the following ideas in case this might help
you ..??.. info below and best of success ... cordially, chuck scott
a) extend your user meta tables with PODS ... the PODS plugin made it
a piece of cake for me to extend the user table with custom variables
and then have those fields as part of their user profile ... in
addition i could set these new user fields so that they could be
edited / changed by one role (e.g., editor, teacher or other custom
role defined) as well as make them not editable (or not viewable) to
the user ...
once you have some name-value pairs that make sense for your team,
next i would go about creating custom page templates in child theme
that then check the usermeta table for permission to access that page
...
b) okay this might not be ideal for a large class, but you might think
of creating custom page templates for each student and then put some
code in those pages to check to see if the person accessing that page
is that student or a teacher and if so, edit away ... thus if you
create a custom page template called student.php then for a class of
thirty people, you would have 30 copies of that file, each modified to
the student name or id - e.g., student-charlie.php, student-fred.php,
student-mary.php, student-snoopy.php etc ... then in each page you
could use the get_user_meta to go grab the meta value you created via
PODS to see if there is a match to that student and go from there ...
c) an example ... i'm working on a membership site with several sub
sites on the network ... essentially two kinds of network members,
read only, and read-write ... initially i created new roles for the
read-write level and assigned the read-only to subscriber but even
subscriber has ability to add comments so i needed to block that ...
yet i also realized that managing the read-write users by adding them
to multiple sub sites was a bit of pain ... my solution was to use
PODS (note i tried Advance Custom Fields and other plugins and code
but personally found PODS to be easiest, fastest, most intuitive), to
extend the user table by creating some new fields, one of which is
called "membershiptype" ... with this new user field, i could then add
code to custom pages (e.g., like comments.php) to look at the
membershiptype before showing the comment_form(); ... i could also add
filters like the one below to look at the membershiptype during login
to run checks before moving to another level ...
d) with respect to your students accessing their own posts ... i'd
probably use a plugin like Justin Tadlock's Members Plugin to create
the new roles and capabilities you need ... thus with a mix of new
roles, some new user meta values, and some custom page templates
and/or actions/filters - voila -> path to success :>)
-------
Example of filter i put in my custom functionality plugin - this
filter looks at the custom field i created with PODS called
"membershptype" and looks for a value of "Disabled" and if it finds
that to true, prevents the user from logging in ...
/* CS - Check if membership type is flagged */
add_filter( 'wp_authenticate_user', 'cs_auth_login', 10, 1);
function cs_auth_login ( $user ) {
if ( get_user_meta ( $user->ID, 'membershiptype', true ) == 'Disabled' ) {
return new WP_Error ( 'test', __("Sorry - Account Disabled ...") );
}
return $user;
}
- fin -
> I'm setting up a WP site for a class. Each student in the class should have their own PAGE on the site that only they and the instructor has access to. Only the student can EDIT their own page.
>
> All students can create and edit their OWN POSTS.
>
> Any suggestions for plugins or ways to set this up?
>
> Thanks,
>
> David
>
> --------------------------------------------------------------
> David Grogan
> Senior Solutions Specialist
> Educational & Scholarly Technology Services (ESTS) Tufts Technology Service (TTS) Tufts University
> 108 Bromfield Rd
> Somerville, MA 02144
>
--
-------------------------------------------------------------------------------
Chuck Scott -> Information Architect
-------------------------------------------------------------------------------
Specialty -> WordPress Multisite Information Design
-------------------------------------------------------------------------------
Site -> http://ChuckingIt.com - Reflecting on Life,
Business, Entrepreneurship, Innovation & Technology
-------------------------------------------------------------------------------
What's New -> Tweeting a bit at @avantigroup
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
More information about the wp-edu
mailing list