iMisagh
Forum Replies Created
-
That solved it, thank you very much Gabriel.
My apologies, let me explain the issue here. The original code that you posted:
add_filter( 'mycred_add', 'restrict_subscribers_from_getting_login_points', 10, 3 ); function restrict_subscribers_from_getting_login_points( $reply, $request, $mycred ) { // If something else already declined this, respect it if ( $reply === false ) return $reply; // Get the user object $user = get_userdata( (int) $request['user_id'] ); // Get the roles array $roles = $user->roles; // If subscriber is the users role, return false to decline if ( in_array( 'subscriber', $roles )) return false; // all else return $reply; }
It does not award Points for Logging In for subscriber users. That is perfect and exactly what I was looking for. The problem was that for some reason, this code stopped subscriber users from earning points by posting comments, that is something that I want subscribers to be awarded for.
So your original code and the one that you just posted does the same thing.
So for example, they do not receive awards for posting a comment. How do we fix this?
So with that question, I meant, how to we block subscribers from receiving points for logging in but allow them to receive points for everything else (such as posting comments, registration etc).
I tested this and unfortunately it did not solve the problem. Subscriber user still does not receive any points for posting comments. Is there a typo in your code that I can’t see?
Ah, Gabriel, one problem.
This code seems to stop awarding of ANY points to a user that is a subscriber. So for example, they do not receive awards for posting a comment. How do we fix this?
Two changes need to be made to make this code work correctly.
We need to close a bracket on this line:
if ( in_array( 'subscriber', $roles )) return false;
And we cannot capitalize subscriber, it needs to be lowercase.Thank you for this Gabriel!