Please or Register to create posts and topics.

how can I update a profile value on post add?

I’m currently doing a level system for the forum, but I don’t know how I can update a profile value with the hook, I tried with that:

function submit_info($postID, $topicID) {
 global $asgarosforum;
 $authorId=$asgarosforum->get_post_author($postID);
 echo $exp=get_user_option( "exp", $authorId );
 $exp=$exp+5;
 update_user_option( $authorId, 'exp', $exp, false);
}
add_action('asgarosforum_after_add_post_submit', 'submit_info', 10, 2);

but it doesn’t run, how can I do this? Need I use another hook?

Hello @jevo1900

The code looks fine so far and should run (after adding a new post, not a topic). You just dont see the output because the forum redirects you directly after the execution to the created post.

So what basically is missing is to show the experience-number on the left side of the post by using the asgarosforum_after_post_author hook.

If you want to support the development of Asgaros Forum, you can leave a good review or donate. Thank you very much!

Then, if I want this code run with topics and it’s replies, what hook I need to use? Isn’t necessary print exp.

@jevo1900 For topics you can use the asgarosforum_after_add_topic_submit hook. This hook works exactly the same so that you can call the same function which you also use for the asgarosforum_after_add_post_submit hook.

jevo1900 has reacted to this post.
jevo1900
If you want to support the development of Asgaros Forum, you can leave a good review or donate. Thank you very much!