UBB.Dev
Enable Guests to View All Posts By A User

About:
This FIX/MOD enables Guests (unregistered users) to view all posts that a Registered User has made.

As of UBBT 7.3, if you're a Guest (unregistered user) and you clicked on "View Posts" next to a Registered User's name within the PostList, their MemberProfile, the WhosOnline list, or anywhere else within UBBT, the Guest would be presented with a, "FATAL_NOT_LOGGED" error ("You must be logged in to access this page!") - which is somewhat correct, but...

If you toggled this feature "ON" in the script, Guests would be presented with, "We encountered a problem. The reason reported was: Database error only visible to forum administrators." Admins and other registered users never saw this message, but it did appear in the logs.

This fix corrects that error and allows you to toggle the feature on or off from within the userposts.inc.php script.

This fix applies to all versions of UBBT 7.3 through the current UBBT 7.5.8.


There are two parts to this;

Part 1 is the toggling of the feature from OFF, to ON.
By default, the feature is set so that Guests (unregistered users) cannot view all posts by an individual Registered User.

Part 2 is fixing a bug that was introduced in UBBT 7.3 (released in May 2008) and it still exists today, in UBBT 7.5.8.



PART 1, "The Toggle."
In scripts/userposts.inc.php
Find:

Code
"regonly" => 1,

Replace with:
Code
"regonly" => 0,

UBBT DEFAULT IS: 1
To enable enable Guests to view all posts by a Registered User, change this to "0" as shown above.


PART 2, "The Bug Fix."
In scripts/userposts.inc.php
Find:

Code
 	if (!$page || $page < 1) $page = 1;
$PostsPer = array_get($user, 'USER_TOPICS_PER_PAGE', $config['TOPICS_PER_PAGE']);

Replace with:
Code
 	if (!$page || $page < 1) $page = 1;
if($user["USER_TOPICS_PER_PAGE"] == null) { $user["USER_TOPICS_PER_PAGE"] = $config['TOPICS_PER_PAGE']; }
$PostsPer = array_get($user, 'USER_TOPICS_PER_PAGE', $config['TOPICS_PER_PAGE']);

Done!

Hat tip to Giz for the elegant single-line resolution.
That check appears to have been written by a genius; or quite simply, a very slept ninja ;-)
© UBB.Developers