Fix sync role widget in manage roles

This commit is contained in:
champsupertramp
2016-08-09 18:25:58 +08:00
parent 89b9131966
commit ade3de47b2
3 changed files with 38 additions and 10 deletions
+8 -7
View File
@@ -163,24 +163,25 @@
add_action('um_admin_do_action__mass_role_sync', 'um_admin_do_action__mass_role_sync');
function um_admin_do_action__mass_role_sync( $action ){
global $ultimatemember;
if ( !is_admin() || !current_user_can( 'edit_user' ) ) die();
if ( !is_admin() || !current_user_can( 'edit_user' ) ) wp_die('You don\'t have permissions to access this page.');
if ( !isset($_REQUEST['post']) || !is_numeric( $_REQUEST['post'] ) ) die();
if ( !isset($_REQUEST['post']) || !is_numeric( $_REQUEST['post'] ) ) wp_die('You\'re not allowed to do this.');
$post_id = (int) $_REQUEST['post'];
$post = get_post( $post_id );
$slug = $post->post_name;
if ( $slug != $_REQUEST['um_role'] )
die();
if ( get_post_meta( $post_id, '_um_synced_role', true ) != $_REQUEST['wp_role'] )
die();
wp_die('Invalid community role.');
$um_synced_role = get_post_meta( $post_id, '_um_synced_role', true );
if ( $slug == 'admin' ) {
$_REQUEST['wp_role'] = 'administrator';
update_post_meta( $post_id, '_um_synced_role', 'administrator' );
}else{
update_post_meta( $post_id, '_um_synced_role', $_REQUEST['wp_role'] );
}
$wp_role = ( $_REQUEST['wp_role'] ) ? $_REQUEST['wp_role'] : 'subscriber';