Advanced search  

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Pages: [1]   Go Down

Author Topic: Authenticate Users for Custom Content  (Read 3547 times)

0 Members and 1 Guest are viewing this topic.

tim18

  • Coppermine novice
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 22
Authenticate Users for Custom Content
« on: September 06, 2007, 07:43:27 am »

Hello,

I've made some custom pages that i really don't want guests to see, but rather only proper users.
Ive been looking through lots of the code to try and figure out what i need to add to my pages to make coppermine check for authentication on my custom pages.
The most frustrating thing is i remember reading a post from Gau Gau where he said something about authenticating users, but i simply cannot find it.
I'm fairly certain its not more than one line of code, as i believe most of coppermine's pages are authenticated.

If someone knows the code or the post on user authentication, please reply.

Thanks
Tim
« Last Edit: September 06, 2007, 10:13:04 am by GauGau »
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Authenticate Users for Custom Content
« Reply #1 on: September 06, 2007, 08:09:24 am »

Album properties, change "Album can be viewed by" from "Everybody (public album)" to "Members of the registered group". Explained in the docs - please read before posting. No modification of the code needed.
Logged

tim18

  • Coppermine novice
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 22
Re: Authenticate Users for Custom Content
« Reply #2 on: September 06, 2007, 08:18:13 am »

Sorry,

There is a misunderstanding.

I have created a "custom page", my own page that uses:
Code: [Select]
<?php
define
('IN_COPPERMINE'true);
require(
'include/init.inc.php');
pageheader('Main Forum');
include(
'source_main_forum.php');
pagefooter();
//(!USER_ID) {
?>

to create the menu system around my own content.

This is an entirely seperate page from the coppermine photo gallery. You wrote some code once that allowed a "custom page" to be authenticated.

Sorry for the misunderstanding.

Tim
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Authenticate Users for Custom Content
« Reply #3 on: September 06, 2007, 08:31:45 am »

To check if the visitor is logged in, try using the constant USER_ID:
Code: [Select]
<?php
if (!USER_ID) {
  
// the visitor is a guest
  
cpg_die(ERROR$lang_errors['access_denied'], __FILE____LINE__);
}
?>
Logged

tim18

  • Coppermine novice
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 22
Re: Authenticate Users for Custom Content
« Reply #4 on: September 06, 2007, 08:38:48 am »

Gau Gau,

This worked perfectly. I sincerely thank-you for your time!

Cheers
Tim
Logged
Pages: [1]   Go Up
 

Page created in 0.015 seconds with 19 queries.