Hi @john201502,
I am having a hard time replying to everyone in less than 24h, but I reply to everyone yesterday except 2-3 persons but they are not named John. Can you you reply to the support request to make sure I see it? (also make sure you used the contact form; if you send me a message somewhere else I might not have seen it).
I set to give every user 1000 tokens per day. but I found their token numbers had not reset or accumulated after a day.
You do this through the “Limits”? That should work, I am also using this. How did you set it up?
I want to set up a member class that can be given different tokens, but I don’t know how to write and input the code.
Many of my users do that through roles, as it’s the easiest way to handle this. Then, they use the code I posted here: https://meowapps.com/ai-engine/faq/#limits.
For clarity, I repost it here:
add_filter( 'mwai_stats_credits', function ( $credits, $userId ) {
$user = get_userdata( $userId );
if ( !empty( $user->roles) && is_array( $user->roles ) ) {
foreach ( $user->roles as $role) {
if ( $role === 'premium' ) {
return 50;
}
if ( $role === 'standard' ) {
return 10;
}
}
}
// This will be basically the default value set in the plugin settings
// for logged-in users.
return $credits;
}, 10, 2);
I think it will be better if the author can develop the function with a setting window but not throw some code to the user. not most of the users can understand the code.
You mean the code above? Unfortunately, it’s extremely difficult to develop a nice UI to handle all the use cases possible; it would be a gigantic and complex UI, that wouldn’t be able to cover all the cases. So I have the choice: spend many months or making an UI that will be imperfect, or make it so that the plugin gives you the ability to do really everything you want very easily through code. Of course, being able to write code is important here, but I am happy to share examples, and most of them can be copy/pasted and adapted very easily. Otherwise, you could ask a dev to adapt it for you, and it would take 30mn or so.
If this code is unclear to you, feel free to ask about it here ??
To add it into your WordPress, I suggest using Code Snippets (https://meowapps.com/add-custom-php-code-wordpress/). You can keep your code snippets organized with a little description, so you will always know what it does.