User Activity – Check PHP code and conversion to HTML

Hello,

On the Usage page of the WPMU User Activity plugin, PHP code is displayed as an image, so I can’t copy. I want to use that code in WordPress pages to display the number of users online, etc. I have no PHP knowledge, and tried to type over the PHP code, but when checking this code, I get Syntax errors. Can you please check the code below, and help me with adding correct HTML tags as well so that I can use them, or drop these PHP/HTML code in WordPress Pages? Do I have to add the PHP code to the theme functions.php as well?

<?php  display_user_activity(1440); ?>
<?php echo 'users online in the last 24 hours.'; ?>
<?php user_activity_output(5, 10, ‘<h1 class=“entry-title”>Online Right Now:</h1>', '<p>User: ', '<p></p>', ' </p>', 'yes’, 40); ?>

Thank you in advance for helping me out.

Regards

  • Adam Czajczyk
    • Support Gorilla

    Hey @romanzy,

    I hope you’re well today!

    I changed your code a little bit:

    <?php  display_user_activity(1440); ?>
    <?php echo 'users online in the last 24 hours.'; ?>
    <?php user_activity_output(5, 10, '<h1 class="entry-title">Online Right Now:</h1>', '<p>User: ', '<p></p>', ' </p>', 'yes', 40); ?>

    The difference might be hard to spot at the first glance but it’s all about quotation marks and apostrophes. Anyway, this one is tested on my test WP install and it works.

    You don’t have to add this code to the functions.php file, place it wherever you want to display those data.

    I hope that helped.

    Cheers,

    Adam

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.