#6 users settings page functional, made non-admin Members able to change some...

#6 users settings page functional, made non-admin Members able to change some of their own data using plugin admin functions
parent 7ba0ad0d
......@@ -83,6 +83,8 @@ if(!class_exists('MembersAdmin'))
* When a member which has a user has its e-mail updated, the user's e-mail is updated also.
*/
public function update($mid, $values){
// CASE 1: An admin is updating some member
if(current_user_can($this->adminCapability) && is_array($values)){
global $wpdb, $Members;
$mid = (int)$mid;
......@@ -149,6 +151,44 @@ if(!class_exists('MembersAdmin'))
// Update the actual member
return $wpdb->update($Members->table, $values, array('mid' => $mid));
}
// CASE 2: A member is updating themself
elseif (is_array($values)) {
$mid = (int)$mid;
$u = get_current_user();
if($mid === (int) $u->ID){
global $wpdb, $Members;
// Unset values that a non-administrative member should not be able to change
unset($values['uid']);
unset($values['privileges']);
unset($values['membersince']);
unset($values['paiduntil']);
unset($values['comments']);
// Logic to change emails
if(isset($values['email']) && !filter_var($values['email'], FILTER_VALIDATE_EMAIL)){
unset($values['email']);
}
if(isset($values['email'])) {
if($uid == null) {
$uid = $Members->getSingle($mid)->uid;
}
wp_update_user(array(
'ID' => $u->ID,
'user_email' => $values['email']
));
}
// Update the actual member
return $wpdb->update($Members->table, $values, array('mid' => $mid));
}
return false;
}
return false;
}
......
......@@ -60,6 +60,7 @@ label, fieldset>legend {
background: transparent;
border: 1px solid @brown;
color: @brown;
padding: calc(~"0.5em - 1px") calc(~"0.8em - 1px");
&:hover {
color: @link-red;
......@@ -103,7 +104,6 @@ fieldset.blocky-checkboxes {
.gradient(@palebeige, @midbeige);
color: @brown;
font-weight: normal;
.transition-lazy();
text-align: center;
position: relative;
line-height: 1.1;
......
......@@ -101,12 +101,15 @@ article img {
// This is error messages and the like,
.main-msg {
padding: 0.5em 0.8em 0.3em;
border-radius: 1ex;
padding: 0.5em 0.8em;
margin-top: -25px;
color: @turq;
background: fade(@turq, 10%);
border: 2px solid @turq;
&.error {
color: #A00;
background: rgba(150,0,0,0.1);
border-color: #A00;
}
}
\ No newline at end of file
......@@ -76,4 +76,8 @@
<?php if(defined('SPGBG_ERRORMESSAGE')): ?>
<p class="error main-msg"><?php echo SPGBG_ERRORMESSAGE ?></p>
<?php endif; ?>
<?php if(defined('SPGBG_SUCCESSMESSAGE')): ?>
<p class="main-msg"><?php echo SPGBG_SUCCESSMESSAGE ?></p>
<?php endif; ?>
\ No newline at end of file
......@@ -254,5 +254,19 @@
gallery_images.imageZoom();
// BLOCKY CHECKBOXES
$('body').on('change', '.blocky-checkboxes input[type="checkbox"], .blocky-checkboxes input[type="radio"]', function(){
var $this = $(this),
$checkboxes = $this.closest('.blocky-checkboxes').find('input[type="checkbox"], input[type="radio"]'),
$active = $checkboxes.filter(':checked');
$checkboxes.each(function(){
$(this).closest('label').removeClass('active');
});
$active.each(function(){
$(this).closest('label').addClass('active');
})
});
}); /* END document ready */
})(jQuery);
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment