Skip to content

Commit 1e1b4ca

Browse files
committed
Adding optional user registration column
1 parent 38cb645 commit 1e1b4ca

4 files changed

Lines changed: 39 additions & 2 deletions

File tree

readme.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@ Solid Dynamics also provides several dynamic tags under the "Solid Dynamics" sec
2222

2323
This plugin also provides several general use and Elementor specific settings under the menu Solid Dynamics. All settings have to be opted in to. Activating the plugin does not activate any of the settings. Activating the plugin does automatically make the dynamic tags listed above available.
2424

25-
General:
25+
General Settings:
2626

2727
- Disable 404 permalink guessing.
2828
- Disable the enumeration of users using the rest API. Disables `/wp-json/wp/v2/users` and `/wp-json/wp/v2/users/:ID`
29+
- Add a sortable column of registration dates to the Users page
2930

3031
Elementor:
3132

@@ -51,6 +52,10 @@ The code is managed on [github](https://github.com/SolidDigital/solid-dynamics),
5152

5253
== Changelog ==
5354

55+
= 1.8.0 =
56+
2025-01-19
57+
Adding setting to add to the Users page a sortable registration date column
58+
5459
= 1.7.0 =
5560
2024-11-26
5661
- Feature: Update elementor fade in animation css.

settings/settings-fields.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ function wpsf_register_settings( $wpsf_settings ) {
2323
'type' => 'checkbox',
2424
'default' => 0,
2525
),
26+
array(
27+
'id' => 'sort_users_by_registration_date',
28+
'title' => 'Sort Users by Registration Date',
29+
'desc' => 'Adds a column to the Users page that shows a sortable column of registration dates.',
30+
'type' => 'checkbox',
31+
'default' => 0,
32+
),
2633
),
2734
);
2835

settings/settings.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,14 @@ function init() {
4848
add_filter( 'rest_endpoints', [$this, 'disable_user_endpoint'] );
4949
}
5050

51+
if ($settings['general_sort_users_by_registration_date']) {
52+
// Idea from https://rudrastyh.com/wordpress/sortable-date-user-registered-column.html
53+
add_filter( 'manage_users_columns', [$this, 'add_registration_date_column'] );
54+
add_filter( 'manage_users_custom_column', [$this, 'get_registration_date'], 10, 3 );
55+
// Make registration date sortable
56+
add_filter( 'manage_users_sortable_columns', [$this,'make_registration_date_sortable'] );
57+
}
58+
5159
if ($settings['elementor_hide_back_to_wp_editor_button']) {
5260
add_action( 'admin_head', [$this, 'elementor_hide_back_to_wp_editor_button'] );
5361
}
@@ -112,4 +120,21 @@ function main_close() {
112120
function elementor_subtle_fade_in_entrance_animations() {
113121
wp_enqueue_style('sd-elementor-subtle-fade-in-entrance-animations', plugin_dir_url(__DIR__) . 'assets/elementor-subtle-fade-in-entrance-animations.css', ['e-animations'], '1.0.0');
114122
}
123+
124+
function add_registration_date_column( $columns ) {
125+
$columns[ 'registration_date' ] = 'Registration Date';
126+
return $columns;
127+
}
128+
129+
function get_registration_date( $row_output, $column_id_attr, $user ) {
130+
$date_format = 'j M, Y H:i';
131+
if ($column_id_attr == 'registration_date') {
132+
$row_output = date( $date_format, strtotime( get_the_author_meta( 'registered', $user ) ) );
133+
}
134+
return $row_output;
135+
}
136+
137+
function make_registration_date_sortable( $columns ) {
138+
return wp_parse_args( array( 'registration_date' => 'registered' ), $columns );
139+
}
115140
}

solid-dynamics.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/**
44
* Plugin Name: Solid Dynamics
55
* Description: Helpful utilities for Elementor, Jet Engine, and beyond.
6-
* Version: 1.7.0
6+
* Version: 1.8.0
77
* Author: Solid Digital
88
* Author URI: https://www.soliddigital.com
99
* License: GPLv2

0 commit comments

Comments
 (0)