• Hi all,

    I am interested to add a notification counter bubble at the “Users” section on the WP admin bar whenever a new user is registered. How would I go about this?

    Kind regards,
    CG

Viewing 3 replies - 1 through 3 (of 3 total)
  • I would count the number of users that registered than an hour ago. Then display it to the admin bar.

    Count users –

    <?php 
    	$arrUsers = get_users();
    	$strDate = date("Y-m-d H:i:s", strtotime('-1 hour'));
    	$intNewUsers = 0;
    	if(is_array($arrUsers)) {
    		foreach ($arrUsers as $key => $value) {
    			if($key == "user_registered" && $value > $strDate) {
    				$intNewUsers++;
    			}
    		}
    	}
    	echo $intNewUsers." New Users Since ".$strDate;
    ?>

    My code might not be accurate, but its a good start:)
    Alter the admin bar – https://www.isitwp.com/add-links-to-wordpress-3-3-new-toolbar/

    • This reply was modified 5 years, 8 months ago by bcworkz. Reason: code fixed
    Moderator bcworkz

    (@bcworkz)

    Hey @unfinishedcode, when you post code in these forums, please demarcate with backticks or use the code button. Otherwise the forum’s parser corrupts your code, making it difficult for others to use it. I fixed the code in your last reply to this topic so consuleregroup can use it without encountering syntax errors.

    Awesome, thanks dude. Will do so in the future.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘WP Admin bar – Adding notification counter bubble’ is closed to new replies.