• Resolved audreyprice

    (@audreyprice)


    I am not sure if you’ll see it on a previous closed post so I will ask here so it’s fresh.

    Previously, I had my member directory set to display the total number of registered members, and then the total number of registered members by specific user role.

    They all worked fine.

    This is the shortcode used

    [total_user_count role=”um_basic”]
    [total_user_count role=”um_premium”]

    So the shortcodes would show the number itself. Now it’s just showing the whole shortcode.

    In a previous thread you (Champ) provided a wp hook add filter for something that needed to go in the scripts.js or customizer but the theme doesn’t have that js file, and the customizer section has styles.css, theme-defaults.php and customizer.php and those throw back and error and show the string on the actual page.

    wp.hooks.addFilter( ‘um_member_directory_generate_header’, ‘um_customizations’, function( generate ) {
    generate = true;
    return generate;
    }, 10 );

    I don’t know where to put that and whether I even need it if I can use the shortcodes…and why they are not working.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @audreyprice

    1. You can try this code snippet for displaying the total users with shortcode:

    add_shortcode("um_total_members", function( $atts ){
        
        $count_users = count_users();
        $atts = shortcode_atts( array(
            'role' => null,
        ), $atts );
    
        extract( $atts );
    
        if( $role ){
            return $count_users['avail_roles'][ $atts['role'] ];
        }
    
        return $count_users['total_users'];
    });

    This will display total users: [um_total_members]
    This one will display total users of specific role: [um_total_members role="subscriber"]

    2. You can use this plugin to insert javascript: https://www.ads-software.com/plugins/insert-headers-and-footers/

    Regards,

    Thread Starter audreyprice

    (@audreyprice)

    Thanks! Where do I add this code?

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @audreyprice

    For the PHP, you can add it to your theme/child-theme functions.php file or use the Code Snippets plugin to run the code.
    https://www.ads-software.com/plugins/code-snippets/

    Regards,

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @audreyprice

    This thread has been inactive for a while so we’re going to go ahead and mark it Resolved.

    Please feel free to re-open this thread by changing the Topic Status to ‘Not Resolved’ if any other questions come up and we’d be happy to help. ??

    Regards,

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Show Total Number Of Registered Users By User Role’ is closed to new replies.