• Welcome to the Chevereto User Community!

    Here, users from all over the world come together to learn, share, and collaborate on everything related to Chevereto. It's a place to exchange ideas, ask questions, and help improve the software.

    Please keep in mind:

    • This community is user-driven. Always be polite and respectful to others.
    • Support development by purchasing a Chevereto license, which also gives you priority support.
    • Go further by joining the Community Subscription for even faster response times and to help sustain this space
  • Chevereto Support CLST

    Support response

    Support checklist

    • Got a Something went wrong message? Read this guide and provide the actual error. Do not skip this.
    • Confirm that the server meets the System Requirements
    • Check for any available Hotfix - your issue could be already reported/fixed
    • Read documentation - It will be required to Debug and understand Errors for a faster support response

User based conditionals

SMP

💖 Chevereto Fan
Would like to know how add advertising per user...

Kindly help me achieve this

if user 1 { user 1 adcode }
else if user 2 { user 2 adcode }
else { site adcode}

If possible give me the conditional statements to do this and where to place it.

Thanks
 
It should be something like...

PHP:
switch(CHV\Login::getUser()['id']) {
    case 1:
        $ad_code = 'ad code 1';
    break;
    case 2:
        $ad_code = 'ad code 2';
    break;
    default:
        $ad_code = 'ad code default';
    break;
}
echo $ad_code;

Place this directly in the theme files. It won't work adding this code in the Dashboard.
 
  • Like
Reactions: SMP
Oops... i show have been more clear with my question. Sorry.

The above code is good to display some sort of message to logged in users.



What i want to achieve is... i want to place adverts like...

user 1's ad code to display only on the images uploaded buy user 1 (and only when not logged in if possible)

and similarly rest.

_____

if user is not logged in {

if user 1 image
{ adcode 1 }
if user 2 image
{ adcode 2 }
else
{user default}

}
else
{ site default }

User (ones i permit) who adds content gets rewarded... and when user are logged in they don't make impressions or accidental clicks on their own ads.
 
Last edited:
You have to play with the CHV\Login functions to do your conditionals. Check app/lib/classes/class.login.php for a complete reference.
 
Hi Rodolfo,

tried and did get it working in parts

On image page used this and its seems to work... so is it correct ?

PHP:
<?php
if(!CHV\Login::isLoggedUser()) {
if(get_image()["user"]["id"]==A) {
?>
Image A
<?php   
} else if(get_image()["user"]["id"]==B) {
?>
Image B
<?php   
} else if(get_image()["user"]["id"]==C) {
?>
Image C
<?php
} else {
?>
Default Image
<?php
}
} else {
?>
Default Site
<?php
}
?>


And on rest what should be the changes... ie... the condition to replace if(get_image()["user"]["id"]==A)

Thanks
 
get_image()["user"] will return the user owner of the image. For logged user you must use CHV\Login
 
get_image()["user"] will return the user owner of the image. For logged user you must use CHV\Login

The thing here is that I am looking to get the content/image owner (as I am planning to share revenue with few selected ones for there contribution) so i think image owner is the correct one on image view page, album owner on album and profile owner on profile page. And rest of them is for default.

So, if I use get logged in user... wont i display based on user rather then image/profile/album?

If A uploads a image... the code should be shown only on that uploaded image view page (like wise with albums & profile) this way the revenue goes only for the things user worked for.

Am I right ?
 
Back
Top