I’m trying to add users for a specific website but want to send the invitation to a big group, without having to fill in an email.
Is this possible? and so yes, how can I do this.
I’m trying to add users for a specific website but want to send the invitation to a big group, without having to fill in an email.
Is this possible? and so yes, how can I do this.
so
you want to add users for a website in matomo but skip the whole email stuff? makes sense, especially for big groups. as far as i know, matomo kind of requires an email to send the invite. it’s like a mandatory step, you know
unfortunately, there isn’t a built-in step way to bypass this and just add users without emailing. maybe you could use a shared or generic email for this purpose? it’s not the cleanest solution, but might get the job done for your groups
yeah, I thought about that too. I hoped it could be done differently, but if there’s no other solution than that’s how we’ll do it, thanks!
You could get around this by using the API method UsersManager.addUser sending this as a POST request in a script would allow you to create users without sending an email invite.
You would also have to create a token auth for this to work. https://matomo.org/faq/general/faq_114/
A quick PHP script that would allow you to add a user:
<?php
// Matomo API endpoint
$apiUrl = 'https://your-matomo-instance-url/index.php';
// API method to add a user
$apiMethod = 'UsersManager.addUser';
// API token for authentication
$apiToken = 'YOUR_API_TOKEN';
// User details
$userLogin = 'newuser'; //Replace with the username to create
$password = 'newpassword'; // Replace with a more secure method for handling passwords
$email = 'newuser@example.com'; //Enter the users email address
$alias = 'User Alias'; //The users alias name
// Prepare the API request data
$data = array(
'module' => 'API',
'method' => $apiMethod,
'format' => 'json',
'token_auth' => $apiToken,
'userLogin' => $userLogin,
'password' => $password,
'email' => $email,
'alias' => $alias
);
// Initialize cURL
$ch = curl_init();
// Set the cURL options for the API request
curl_setopt($ch, CURLOPT_URL, $apiUrl);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Execute the API request
$response = curl_exec($ch);
// Check for errors
if (curl_errno($ch)) {
echo 'Error: ' . curl_error($ch);
} else {
// Decode the API response
$responseData = json_decode($response, true);
// Display the API response
echo 'API Response: ';
print_r($responseData);
}
// Close cURL
curl_close($ch);
?>
Thank you! This is a much faster and easier way. Will try this one!