Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Just return number from get_users_browsing_page #20

Open
bash88 opened this issue Aug 27, 2019 · 6 comments
Open

Just return number from get_users_browsing_page #20

bash88 opened this issue Aug 27, 2019 · 6 comments

Comments

@bash88
Copy link

bash88 commented Aug 27, 2019

Hi,

I don't see any way to just return a number from get_users_browsing_page, so I brute forced myself a way to do it. Probably all wrong.

Is this something you could maybe include in the plugin?

@lesterchan
Copy link
Owner

Maybe try UserOnline_Template::compact_list( 'page', 'list', $page_url ) Code is https://github.com/lesterchan/wp-useronline/blob/master/template-tags.php#L111

@bash88
Copy link
Author

bash88 commented Aug 27, 2019

Thank you very much for your quick response!

I went with:
count( UserOnline_Template::compact_list( 'page', 'list', '' ) )

Only now it's not updating real-time, right? Is there any way to fix that?

@lesterchan
Copy link
Owner

Nope. It is totally different. This just basically counts the user at the point in time. If you want real time, you need to write your own AJAX calls to an endpoint that calls that line.

@bash88
Copy link
Author

bash88 commented Aug 27, 2019

Well, the real-time update does happen but it switches the output back to html..

<span id="useronline-browsing-page"><strong>2 Bezoekers</strong> Bezoeken deze pagina.<br>Gebruikers: <strong>2 Gasten</strong></span>

@lesterchan
Copy link
Owner

@bash88
Copy link
Author

bash88 commented Aug 27, 2019

Awesome, that works. But I'd rather not have custom code in the plugin of course. Do you think you can include this in the plugin? Something like:

users_browsing_page($page_url, $number_only);

Or maybe a global setting to bypass templates and just return numbers?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants