activate or remove signups
Showing
2 changed files
with
108 additions
and
0 deletions
| ... | @@ -148,6 +148,16 @@ function create_user() { | ... | @@ -148,6 +148,16 @@ function create_user() { |
| 148 | require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'create_user.php'); | 148 | require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'create_user.php'); |
| 149 | } | 149 | } |
| 150 | 150 | ||
| 151 | function signups() { | ||
| 152 | require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'signups.php'); | ||
| 153 | } | ||
| 154 | |||
| 155 | function _get_signups() { | ||
| 156 | global $wpdb; | ||
| 157 | $users = $wpdb->get_results("SELECT * FROM wp_signups WHERE active = 0 ORDER BY registered ASC"); | ||
| 158 | return $users; | ||
| 159 | } | ||
| 160 | |||
| 151 | class ProfileValidation extends Common\Validation { | 161 | class ProfileValidation extends Common\Validation { |
| 152 | public function prefix($val) { | 162 | public function prefix($val) { |
| 153 | update_user_meta($_POST['uid'], __FUNCTION__, $val); | 163 | update_user_meta($_POST['uid'], __FUNCTION__, $val); |
| ... | @@ -475,6 +485,26 @@ function run_validation() { | ... | @@ -475,6 +485,26 @@ function run_validation() { |
| 475 | 485 | ||
| 476 | class Actions { | 486 | class Actions { |
| 477 | 487 | ||
| 488 | public static function wp_ajax_override_activate() { | ||
| 489 | global $wpdb; | ||
| 490 | $activation_key = $_POST['akey']; | ||
| 491 | Auth\activate($_POST['akey']); | ||
| 492 | $return = array( | ||
| 493 | 'success' => 'true' | ||
| 494 | ); | ||
| 495 | die(json_encode($return)); | ||
| 496 | } | ||
| 497 | |||
| 498 | public static function wp_ajax_override_remove() { | ||
| 499 | global $wpdb; | ||
| 500 | $activation_key = $_POST['akey']; | ||
| 501 | $wpdb->query("DELETE FROM wp_signups WHERE activation_key='$activation_key' LIMIT 1"); | ||
| 502 | $return = array( | ||
| 503 | 'success' => 'true' | ||
| 504 | ); | ||
| 505 | die(json_encode($return)); | ||
| 506 | } | ||
| 507 | |||
| 478 | public static function wp_ajax_remove_user() { | 508 | public static function wp_ajax_remove_user() { |
| 479 | 509 | ||
| 480 | $remove_action = $_POST['remove_action']; | 510 | $remove_action = $_POST['remove_action']; |
| ... | @@ -858,6 +888,7 @@ class Actions { | ... | @@ -858,6 +888,7 @@ class Actions { |
| 858 | public static function admin_menu() { | 888 | public static function admin_menu() { |
| 859 | add_menu_page('CBV Users','CBV Users',CAPABILITY,'cbv_users',__NAMESPACE__ . '\display_users',null,3 ); | 889 | add_menu_page('CBV Users','CBV Users',CAPABILITY,'cbv_users',__NAMESPACE__ . '\display_users',null,3 ); |
| 860 | add_submenu_page('cbv_users','New User', 'New User',CAPABILITY,'cbv_users_create',__NAMESPACE__ . '\create_user'); | 890 | add_submenu_page('cbv_users','New User', 'New User',CAPABILITY,'cbv_users_create',__NAMESPACE__ . '\create_user'); |
| 891 | add_submenu_page('cbv_users','New User', 'Awaiting Validation',CAPABILITY,'cbv_users_signups',__NAMESPACE__ . '\signups'); | ||
| 861 | } | 892 | } |
| 862 | 893 | ||
| 863 | public static function admin_init() { | 894 | public static function admin_init() { | ... | ... |
com/UserManager/views/signups.php
0 → 100644
| 1 | <?php | ||
| 2 | namespace Tz\WordPress\Tools\UserManager; | ||
| 3 | |||
| 4 | use Tz, Tz\Common; | ||
| 5 | use Tz\WordPress\CBV; | ||
| 6 | use Exception, StdClass; | ||
| 7 | |||
| 8 | $users = _get_signups(); | ||
| 9 | |||
| 10 | |||
| 11 | |||
| 12 | |||
| 13 | ?> | ||
| 14 | <div id="" class="wrap"> | ||
| 15 | <div id="icon-users" class="icon32"><br /></div> | ||
| 16 | <h2>Users awaiting validation</h2> | ||
| 17 | <p style="display:none;">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam iaculis convallis nisi eu dignissim. Quisque malesuada augue in mi blandit at blandit tortor sollicitudin. Cras at justo mi, vel mollis est. Donec orci erat, blandit varius vehicula vitae, volutpat at lorem. Etiam tincidunt bibendum ante, non tincidunt purus faucibus sed. Suspendisse eget facilisis tellus. Nulla imperdiet leo placerat diam sollicitudin nec mattis neque mattis. Cras id lacus tellus. Phasellus volutpat vehicula porttitor. Praesent erat felis, pharetra mollis egestas sit amet, rhoncus eget nisl. Morbi interdum sapien vitae nibh pharetra scelerisque. Mauris porta accumsan velit ac aliquam. Sed sit amet dictum felis. Fusce tempus vulputate nulla, quis tincidunt velit mattis eu.</p> | ||
| 18 | |||
| 19 | <table cellspacing="0" class="widefat post fixed" style="margin-top:20px;"> | ||
| 20 | <thead> | ||
| 21 | <tr> | ||
| 22 | <th width="200">Login</th> | ||
| 23 | <th>Email</th> | ||
| 24 | <th width="200">Date Registered</th> | ||
| 25 | <th width="200"> </th> | ||
| 26 | </tr> | ||
| 27 | </thead> | ||
| 28 | <tbody> | ||
| 29 | <?php foreach($users as $user): ?> | ||
| 30 | <tr> | ||
| 31 | <td><?php echo $user->user_login; ?></td> | ||
| 32 | <td><a href="mailto:<?php echo $user->user_email; ?>"><?php echo $user->user_email; ?></a></td> | ||
| 33 | <td><?php echo date("M j, Y @ h:ia",strtotime($user->registered)); ?></td> | ||
| 34 | <td style="text-align:right;"><a href="#" class="activate" rel="<?php echo $user->activation_key;?>">Activate</a> | <a href="#" class="remove" rel="<?php echo $user->activation_key;?>">Remove</a></td> | ||
| 35 | </tr> | ||
| 36 | <?php endforeach;?> | ||
| 37 | </tbody> | ||
| 38 | </table> | ||
| 39 | </div> | ||
| 40 | |||
| 41 | <script type="text/javascript"> | ||
| 42 | jQuery(document).ready(function($) { | ||
| 43 | |||
| 44 | $('.activate').click(function(e) { | ||
| 45 | var activation_key = $(this).attr('rel'); | ||
| 46 | |||
| 47 | $.ajax({ | ||
| 48 | url: '/wp-admin/admin-ajax.php' | ||
| 49 | , dataType: 'json' | ||
| 50 | , type: 'POST' | ||
| 51 | , data: ({ajax:"yes", action: 'override_activate', akey: activation_key}) | ||
| 52 | , success: function(date) { | ||
| 53 | document.location.href = document.location.href; | ||
| 54 | } | ||
| 55 | }); | ||
| 56 | e.preventDefault(); | ||
| 57 | return false; | ||
| 58 | }); | ||
| 59 | |||
| 60 | $('.remove').click(function(e) { | ||
| 61 | var activation_key = $(this).attr('rel'); | ||
| 62 | |||
| 63 | $.ajax({ | ||
| 64 | url: '/wp-admin/admin-ajax.php' | ||
| 65 | , dataType: 'json' | ||
| 66 | , type: 'POST' | ||
| 67 | , data: ({ajax:"yes", action: 'override_remove', akey: activation_key}) | ||
| 68 | , success: function(date) { | ||
| 69 | document.location.href = document.location.href; | ||
| 70 | } | ||
| 71 | }); | ||
| 72 | e.preventDefault(); | ||
| 73 | return false; | ||
| 74 | }); | ||
| 75 | |||
| 76 | }); | ||
| 77 | </script> | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
-
Please register or sign in to post a comment