Number of members in a directory

[ad_1]

Hello @todd402,

The member directory displays a number of found members by default if you use searching. You need custom code to display a number of members only if you don’t use searching.

You may see a number of members twice if you use searching and a code from the article. You have to modify the code if you want to remove the default block with the number of found members before adding a custom block with the number of members.

add_action( 'um_members_directory_before_head', 'um_021422_show_total_members' );
function um_021422_show_total_members() {
	?>
		<script type="text/javascript">
		jQuery(function(){
			wp.hooks.addAction( 'um_member_directory_loaded', 'um', function(directory, data) {
				if( false === data.is_search ){
					directory.find('.um-members-wrapper .um-members-intro').remove();
					directory.find('.um-members-wrapper').prepend('<div class="um-directory-total-members um-members-intro"><div class="um-members-total">Total Members: ' + data.pagination.total_users + '</div></div>');
				}
			});
		});
		</script>
	<?php
}

Regards

That works perfectly, thanks for getting back with the solution so quickly.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer