Created
July 5, 2017 19:34
-
-
Save prudentbot/27d20e63f5b28c67cc0fc8845dc2c72e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: Starling Users Table | |
Plugin URI: tylerbuilds.website | |
Description: Changes the columns on the Users page. | |
Version: 1.0 | |
Author: Tyler Smith | |
Author URI: tylerbuilds.website | |
License: GPL2 | |
*/ | |
function starling_get_approval_controls ($user_id) { | |
$approve = | |
'<form action="' . esc_url( admin_url("admin-post.php") ) . '" method="post"> | |
<input type="hidden" name="id" value="' . $user_id . '"> | |
<input type="hidden" name="action" value="approve_user"> | |
<input type="submit" value="Approve"> | |
</form>'; | |
$reject = | |
'<form action="' . esc_url( admin_url("admin-post.php") ) . '" method="post"> | |
<input type="hidden" name="id" value="' . $user_id . '"> | |
<input type="hidden" name="action" value="reject_user"> | |
<input type="submit" value="Reject"> | |
</form>'; | |
$suspend = | |
'<form action="' . esc_url( admin_url('admin-post.php') ) . '" method="post"> | |
<input type="hidden" name="id" value="' . $user_id . '"> | |
<input type="hidden" name="action" value="suspend_user"> | |
<input type="submit" value="Suspend"> | |
</form>'; | |
$unsuspend = | |
'<form action="' . esc_url( admin_url("admin-post.php") ) . '" method="post"> | |
<input type="hidden" name="id" value="' . $user_id . '"> | |
<input type="hidden" name="action" value="reactivate_user"> | |
<input type="submit" value="Unsuspend"> | |
</form>'; | |
if(get_user_meta($user_id, 'is_approved', true)) | |
return $suspend; | |
if(get_user_meta($user_id, 'is_rejected', true)) | |
return $approve; | |
if(get_user_meta($user_id, 'is_suspended', true)) | |
return $unsuspend; | |
return $approve . $suspend; | |
} | |
add_action('manage_users_custom_column', 'starling_user_column_content', 10, 3); | |
function starling_user_column_content($value, $column_name, $user_id) { | |
if ($column_name == 'approval_controls'){ | |
return starling_get_approval_controls($user_id); | |
} | |
return $value; | |
} | |
add_action('manage_users_columns','starling_modify_user_columns'); | |
function starling_modify_user_columns($column_headers) { | |
$column_headers['approval_controls'] = 'Controls'; | |
return $column_headers; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment