Cannot Redeclare Function
-
Hi I want to use a code snippet but I receive the error “Cannot redeclare function wpb_user_count.” How can I fix it?
Here’s the code:
// Function to show the user count by role via shortcode function wpb_user_count($atts) { $atts = shortcode_atts( array( ‘role’ => ” ), $atts ); $user_query = new WP_User_Query( array( ‘role’ => $atts[‘role’] ) ); // Get the total number of users for the current query. I use (int) only for sanitize. $result = (int) $user_query->get_total(); return $result; } // Creating a shortcode to display user count add_shortcode(‘user_count’, ‘wpb_user_count’); // Use this Shortcode to show user [user_count role=”Subscriber”]
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Cannot Redeclare Function’ is closed to new replies.