I have a question about the possibility of a user count from another site. The company I work at has an account for every employee on our main-site WordPress, which we display on the our-people page, making it dynamic.
The company I work at also has a website for a specific product with a employee-counter, only it is static.
Is it possible to get the user count from our main website and display it on our product-website, dus making it dynamic?
Thanks for all the replies!
EDIT: Think it might be possible with a AJAX request, but don't know how...
@misorude The other site is also WordPress. With static I only meant the employee number is static, and needs to be dynamic. The sites are hosted at the same provider, but on different packets.
EDIT 2: The new problem is basically this: How do I let only the client side interact with those API calls? I don't want those API calls to be public and be called by simply entering the link on browser.
edit 3:
function getUserAmount() {
$users = get_users();
if ( empty( $users ) ) {
return 'There aren\'t any users to display.';
}
return count($users);
}
/* Preparing to serve an API request */
add_action( 'rest_api_init', function () {
register_rest_route( 'myplugin/v2', '/wp/colleagues',
array(
'methods' => 'GET',
'callback' => 'getUserAmount',
)
);
} );
How can I make it public? I can only get the data if i'm logged in.