As the title suggests I would like to receive the topic author as an integer I am using it in conjunction with myCRED, so far, I have tried this:

$user_id = bbp_get_topic_author_id(  $topic_id = 0 );
$mycred  = mycred();

if ( ! $mycred->exclude_user( $user_id ) )
    $mycred->update_users_balance( $user_id, 1 );

I assumed bbp_get_topic_author_id returned a integer like get_current_user_id but the script acted as if the line didn't exist and continued with the rest of the plugin. This makes me assume that it is returning some variable but cannot be understood by mycred. Thanks in advance.

P.S I am unsure what to tag this so I have only selected bbpress


The problem is that $user_id = bbp_get_topic_author_id( $topic_id = 0 ) is malformed. You need to remove the = 0 from $topic_id = 0 and make sure that the variable $topic_id actually contains the ID of the topic you are trying to get the author of.

  • Thanks. I have done this and added $topic_id = bbp_get_topic_id(); above the other code, but it doesn't update the points and passes through the rest of the plugin. Sorry if I am being stupid. – tejt Jul 30 '19 at 13:24
  • Have you confirmed that all else in your code is being populated properly? Eg, if you var_dump $topic_id, $user_id and $mycred do you see what you expect? I don't recognise the function mycred(), so perhaps the problem is happening in there? Where is it defined? Is it yours or part of another plugin? – Peter HvD Jul 30 '19 at 15:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.