Notifications
Clear all

wpForo 1.x.x [Closed] I need to code a small program

5 Posts
3 Users
0 Reactions
1,768 Views
Lonnie Ray
Posts: 3
Topic starter
(@the-alpha)
Active Member
Joined: 7 years ago

What would be the best way to start? All I want to do is write a small pease of code that I can put in a template file that will check to see if the forum user has 5 or more posts if so it will just load the page, if not it will redirect to another page. Anyone, nowhere I might start. I know I will need to do a database query and evaluate the post count then run a condition. Can you tell me the database table that holds the post count for a user? And maybe a small example?

Thank You

4 Replies
Sofy
Posts: 5006
 Sofy
Admin
(@sofy)
Support Team
Joined: 7 years ago

Hi Lonnie Ray,

We'll try to find some solution for you. I'll update this topic once I got some news for you.

Lonnie Ray
Posts: 3
Topic starter
(@the-alpha)
Active Member
Joined: 7 years ago

Thank you very much. It has been years since I coded and forgot most everything. I can hold my own if I have a starting point. This is all I have come up with and is totally wrong. I have to do a check for the user ID and count there posts then evaluate. 

 

<?php
$post_count = $wpdb->get_var( "
SELECT `x5_wpforo_profiles`.`posts`
FROM `x5_wpforo_profiles`
WHERE (`x5_wpforo_profiles`.`posts` >=5)
" );

if ($post_count > 5) {echo "is 5 or more";}
elseif ($post_count < 5) {echo "is not 5 or more";}

echo "<p>Post Count {$post_count} </p>";
?>

Robert
Posts: 10591
Admin
(@robert)
Support Team
Joined: 9 years ago

This code may helpful:

if(function_exists('wpforo_member')){
$current_member = wpforo_member( get_current_user_id() );
if( wpfval($current_member, 'posts') && $current_member['posts'] >= 5 ){
echo "is 5 or more";
}
else{
echo "is less 5";
}
}
1 Reply
Lonnie Ray
(@the-alpha)
Joined: 7 years ago

Active Member
Posts: 3

hay thank you very much... it works just fine