AI Search
Classic Search
 Search Phrase:
 Search Type:
Advanced search options
 Search in Forums:
 Search in date period:

 Sort Search Results by:

AI Assistant
Notifications
Clear all

[Closed] I need to code a small program

5 Posts
3 Users
0 Reactions
2,318 Views
Lonnie Ray
Posts: 3
Topic starter
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@the-alpha)
Active Member
Joined: 8 years ago
[#6082]

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: 5774
 Sofy
Admin
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@sofy)
Support Team
Joined: 8 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
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@the-alpha)
Active Member
Joined: 8 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: 10746
Admin
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@robert)
Support Team
Joined: 3 months 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: 8 years ago

Active Member
Posts: 3
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian

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


Share: