Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7613199
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T02:06:00+00:00 2026-05-31T02:06:00+00:00

I have created a function in one of my Joomla PHP files. Essentially, the

  • 0

I have created a function in one of my Joomla PHP files. Essentially, the function checks to see if a user’s ID is found in a database. If the user’s ID is not found, then it redirects to Content-A. If the user’s ID is found in the database, then it redirects to Content B. In the code below, if $result returns true, then the user’s ID was found.

Here it is in the current working form:

    else

    {

        // Get Current Users Joomla ID            
        $user =& JFactory::getUser();        

        // Search Database for Joomla Users ID

        $db = JFactory::getDbo();
        $query = $db->getQuery(true);
        $query->select('user_id');
        $query->from('database_table');
        $query->where('user_id = ' . $user->id);
        $db->setQuery($query);
        $result = $db->loadResult();  

    if ($result && ((JRequest::getCmd('option') != 'com_content') || (JRequest::getCmd('view') != 'article') || (JRequest::getInt('id') != 'XXX')))

{ 

This code says if there is a $result, and the current page loaded in the browser is not content id XXX, then execute the following function. What I need to do is also include 2 other page id’s to check. So if the user is on one of these three page IDs, then they won’t be redirected.

I’ve tried the following, but it doesn’t seem to work:

    if ($result && ((JRequest::getCmd('option') != 'com_content') || (JRequest::getCmd('view') != 'article') || ((JRequest::getInt('id') != 'XXX') || (JRequest::getInt('id') != 'YYY') || (JRequest::getInt('id') != 'ZZZ'))))

{

I think I’m close, but site goes into a redirect loop when I save this code. Can someone suggest a way to fix the syntax? Thanks in advance for any help!

EDITS: There are really 4 content types that need to be handled in this workflow.

Content-A = Display if the user is logged in and their user ID is not found in a database

Content-B = Display if the user is logged in and their user ID is found in a database

Content-C = Is accessed from Content-B through a Link

Content-D = Is displayed on Content A, B & C through a light box pop up (RocketTheme’s RokBox)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T02:06:01+00:00Added an answer on May 31, 2026 at 2:06 am

    Just made it a bit clean ,simple if condition will help to find the problem.

    $articleId = (JRequest::getVar('option')==='com_content' && JRequest::getVar('view')==='article')? JRequest::getInt('id') : 0; //Get the article's ID
    
    $dont_redirect = array('12','13','15'); //ID's of those specific articles
    
    if($result && !in_array($articleId , $dont_redirect))
    {
    

    If it still doesn’t work , it’s probably the $result variable , what’s the value of it?
    Use:

    var_dump($result);
    

    before the condition.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In PHP, I have created a user defined function. Example: <?php function test($one, $two)
I have created one function whose purpose is to add data to database (I'm
PHP mysql database I have created a follow on question to this one here
I have a strange one. Create a new form. Then add the following function
I have created a function in PHP that calls a webservice and parses through
i have created a module with this among others this function in it: <?php
I have created one service. Now I am trying to access database in onstart()
I have created a function (see below) that calculates a 7.5% sales tax. Now
I have created one thread for calling native function which are calling the MPEG2
I am developing an android application. Now i have created one function which create

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.