Category: Code Snippets

Check User Group By Group ID

Check User Group By Group ID

There are many scenarios where you may need to check what group(s) a user is in. For example, I use this code to check if users are in my “Sponsors” group. If they are, I don’t display any advertisements for them and I show them a shiny purple star. Snippet Function Example This is how […]

Read more
Get Article Field Values From Anywhere

Get Article Field Values From Anywhere

The following code snippets use Joomla’s Database Classes to retrieve information about any article in the __content table of your Joomla database. Note that every function requires you to use Factory. So be sure to include the use statement at the top of the file you’re using any of these functions in. Remember, querying the […]

Read more
Accessing Custom Article Fields From Template Layouts

Accessing Custom Article Fields From Template Layouts

Suppose you want to create a custom article option in Joomla 4/5. In this example, I’m creating two fields -> “showspecialtext” and “specialtext”.  The “showspecialtext” field will be a boolean with a value of 0 or 1. If it it zero, nothing will happen on the single article page. If it’s 1, it will print […]

Read more
Adding Custom Fields On Extension Install

Adding Custom Fields On Extension Install

Custom Fields may be useful in many Joomla extensions. They can be added by calling a custom script file upon an extension install or uninstall. The script will use Joomla’s database driver to manually insert new custom field records. I created this code to go along with my guide on loading custom article fields within layout […]

Read more
Accessing Custom User Field Values With PHP

Accessing Custom User Field Values With PHP

In my guide on custom user fields in Joomla, I show how to add custom fields to a user’s profile. By default, Joomla only allows you to use these fields to show or save information about users. If you’re a developer, you can use this to programmatically add user-specific functionality to your website.  Scenario Suppose you want […]

Read more
5 guides found