Previous Thread
Next Thread
Print Thread
Rate Thread
Joined: Jan 2009
Posts: 3
whk
Offline
Lurker
Lurker
Offline
Joined: Jan 2009
Posts: 3
This was posted on the UBB Central forum but probably better suited for this forum.

I'm making "Custom Field 1" the location where I will store the link to an external database record for the user who registers. I'd like to make it so this field is only visible by the individual user who is logged in, and Administrators. The record it links to has personal data that I don't want visible to the world or other users.

I found the file showprofile.tpl and deleted {$CUSTOM_FIELD_1} near the end of the script to prevent it from displaying as a temporary work around. Can somebody tell me what the code is so I can replace this:

{$CUSTOM_FIELD_1}
{$CUSTOM_FIELD_2}
{$CUSTOM_FIELD_3}
{$CUSTOM_FIELD_4}


with code that has this logic:

if (Administrator #or# Log in ID = Profile ID being viewed)
{$CUSTOM_FIELD_1}
end if
{$CUSTOM_FIELD_2}
{$CUSTOM_FIELD_3}
{$CUSTOM_FIELD_4}


I am not a programmer, but I do understand the logic. I don't know what the correct variable names are, or the proper syntax for conditionals.

Also - other than the showprofile.tpl file, is there anywhere else where anyone except that user or the administrator would have Custom Field 1 visibility? I'd like to modify those files too.

Ideally this could be a longer term UBB Thread change to the control panel so the fields can be checked as "private" or "public"

Thanks,
Bill

Sponsored Links
Joined: Mar 2000
Posts: 21,079
Likes: 3
I type Like navaho
I type Like navaho
Joined: Mar 2000
Posts: 21,079
Likes: 3
It would be the same code as found in the 'edit user' link that shows up in the profile.


- Allen wavey
- What Drives You?
Joined: Mar 2000
Posts: 21,079
Likes: 3
I type Like navaho
I type Like navaho
Joined: Mar 2000
Posts: 21,079
Likes: 3
Line #305 in showprofile.php gives the code for showing that link (which is called in the template as: {$useredit} ). If you need more assistance, just ask.


- Allen wavey
- What Drives You?
Joined: Jan 2009
Posts: 3
whk
Offline
Lurker
Lurker
Offline
Joined: Jan 2009
Posts: 3
That works!

The showprofile.tpl code now reads:
{if $useredit}
{$CUSTOM_FIELD_1}
{/if}
{$CUSTOM_FIELD_2}
{$CUSTOM_FIELD_3}
{$CUSTOM_FIELD_4}
{$CUSTOM_FIELD_5}


Now where can I change the definition of $CUSTOM_FIELD_1 so it displays as a link instead of text when the profile is viewed? I want to leave it as text in the profile edit screen. This is just like the Homepage field attributes.

I tried
Your DB Link but the {$CUSTOM_FIELD_1} has both label & the URL info and does not provide the correct link.

Joined: Jan 2009
Posts: 3
whk
Offline
Lurker
Lurker
Offline
Joined: Jan 2009
Posts: 3
Ok - I figured this out. I restored showprofile.tpl with the original file and instead modified /scripts/showprofile.inc.php

It isn't optimized because I don't know the syntax for different conditionals and brute forced it, but it works. It allows me to put a custom label and the URL to an external database record in CUSTOM_FIELD_1, and have that field visible only by the individual user, or any administrators. It shows up as a link like the homepage field.

Original Code
Code
	// Show the profile if it exists
$columns = 2;
if ($CheckUser) {

if ($Homepage) {
$Homepage = str_replace("http://","",$Homepage);
$Homepage = str_replace("https://","",$Homepage);
$Homepage = htmlspecialchars($Homepage);
$Homepage = "<a href=\"http://$Homepage\" target=\"new\">http://$Homepage</a>";
}

if ($config['CUSTOM_FIELD_1']) {
$CUSTOM_FIELD_1 = "
<tr><td valign='top'>
{$config['CUSTOM_FIELD_1']}:
</td><td valign='top'>
 $Extra2
</td></tr>
";
}

if ($config['CUSTOM_FIELD_2']) {

Modified Code
Code
	// Show the profile if it exists
$columns = 2;
if ($CheckUser) {

if ($Homepage) {
$Homepage = str_replace("http://","",$Homepage);
$Homepage = str_replace("https://","",$Homepage);
$Homepage = htmlspecialchars($Homepage);
$Homepage = "<a href=\"http://$Homepage\" target=\"new\">http://$Homepage</a>";
}

// If this is the user allow visibility of class database link
if ($User == $user['USER_ID']) {
if ($config['CUSTOM_FIELD_1']) {
$Extra1 = str_replace("http://","",$Extra1);
$Extra1 = str_replace("https://","",$Extra1);
$Extra1 = htmlspecialchars($Extra1);
$CUSTOM_FIELD_1 = "J/30 Record: <a href=\"http://$Extra1\" target=\"new\">http://$Extra1</a>";
}
}

// If this is the main admin user allow visibility of class database link
if ($user['USER_ID'] == $config['MAIN_ADMIN_ID']) {
if ($config['CUSTOM_FIELD_1']) {
$Extra1 = str_replace("http://","",$Extra1);
$Extra1 = str_replace("https://","",$Extra1);
$Extra1 = htmlspecialchars($Extra1);
$CUSTOM_FIELD_1 = "J/30 Record: <a href=\"http://$Extra1\" target=\"new\">http://$Extra1</a>";
}
}

// If this is the any other admin allow visibility of class database link
if (($user['USER_MEMBERSHIP_LEVEL'] == "Administrator") && $Userstatus != "Administrator") {
if ($config['CUSTOM_FIELD_1']) {
$Extra1 = str_replace("http://","",$Extra1);
$Extra1 = str_replace("https://","",$Extra1);
$Extra1 = htmlspecialchars($Extra1);
$CUSTOM_FIELD_1 = "J/30 Record: <a href=\"http://$Extra1\" target=\"new\">http://$Extra1</a>";
}
}

if ($config['CUSTOM_FIELD_2']) {

Sponsored Links

Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
isaac
isaac
California
Posts: 1,157
Joined: July 2001
Forum Statistics
Forums63
Topics37,573
Posts293,925
Members13,849
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2024 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20221218)