A Cozmoslabs Product
Documentation / Developer Knowledge Base / Shortcodes / List unapproved users shortcode

List unapproved users shortcode

This function will make a shortcode you can use to list all unapproved users.

Shortcode:

[unapproved_users]

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/*
 * List unapproved users shortcode.
 * Usage: [unapproved_users]
 */
 
add_shortcode( 'unapproved_users', 'wppbc_unapproved_users' );
function wppbc_unapproved_users( $atts, $content ){
	$term_id = get_term_by( 'slug', 'unapproved', 'user_status');
	$term_tax = 'user_status';
	$users = get_objects_in_term( $term_id->term_id, $term_tax );
 
	if ( !empty( $users ) ) {
		$list = '<ul class="user-entry">';
		foreach ( $users as $user_id ) {
			$user = get_user_by('id', $user_id);
			if ( $user ) {
				$list .= '<li>';
				$list .= get_avatar( get_the_author_meta( 'email', $user_id ), '30' );
				$list .= '<strong style="margin-left: 20px;">'. get_the_author_meta('display_name', $user_id) . '</strong>';
			}
		}
		$list .= '</ul>';
	}
	return $list;
}

Profile Builder Pro

Create beautiful front-end registration and profile forms with custom fields. Setup member directories, custom redirects, cutomize user emails & more using the all in one user management plugin.

Get Profile Builder

The Ultimate Membership Bundle

Combine the power of Profile Builder with Paid Member Subscriptions to set up user registration, memberships, and recurring revenue.

Get 25% off with the bundle

Help & Support

We’re here to help you every step of the way.

Open a Support Ticket