---
title: "PHP Field - Advanced Custom Fields"
description: "Run custom PHP code to display dynamic content. Perfect for developers who want to extend the functionality of their Joomla site."
url: "https://www.tassos.gr/docs/advanced-custom-fields/fields/php"
date: "2026-04-05T23:33:33+00:00"
language: "en-GB"
---

[ Home ](https://www.tassos.gr/index.php?option=com_content&view=category&layout=blog&id=24&Itemid=1088) / [ Advanced Custom Fields ](https://www.tassos.gr/index.php?option=com_content&view=category&id=44) / [ Fields Types ](https://www.tassos.gr/index.php?option=com_content&view=category&id=64)

#  PHP Field

##  Run custom PHP code to display dynamic content. Perfect for developers who want to extend the functionality of their Joomla site.

 PHP Field is available in Pro  Unlock this and dozens of other powerful features by upgrading to Advanced Custom Fields Pro.

 [ Unlock this feature ](https://www.tassos.gr/joomla-extensions/advanced-custom-fields/subscribe)

The PHP custom field gives you the ability to run any PHP code you desire within an Article.[](#how_to_add_a_php_custom_field_to_joomla_articles)

## [How to add a PHP Custom Field to Joomla! Articles](#how_to_add_a_php_custom_field_to_joomla_articles)

The PHP field provides you the way to set the default PHP code to run when you view an Article.

![acf-php-field-settings](https://www.tassos.gr/images/acf-php-field-settings.png)

Let's see what each option does.

 | Name | Description |
|---|---|
| Name | The name will be used to identify the field. Leave this blank and Joomla will fill in a default value from the title. |
| Label | The label of the field to display. |
| Description | A description of the field that will be displayed in the label tooltip. |
| Required | Is this a mandatory field? |
| Default Value | Set the default PHP code |

## [Blocking specific PHP functions](#blocking_specific_functions)

The PHP field allows you to create a list of forbidden php functions. If any of these functions are found within the php code, then the whole php block of code will not be executed.

To edit the list, you can do so by going on **Extensions** &gt; **Plugins** &gt; **Fields - ACF PHP** &gt; **Forbidden PHP Functions**. You can see the list of the forbidden php functions below.

![acf-php-forbidden-php-functions](https://www.tassos.gr/images/acf-php-forbidden-php-functions.png)

In the textarea, you enter a comma separated list of functions.

## [Usage](#usage)

Once you are in your Article's Edit screen, choose the "Fields" Tab to see the PHP custom field as you can see in the screenshot below.

![acf-php-field-usage](https://www.tassos.gr/images/acf-php-field-usage.png)

In the textarea, you enter your own PHP code to run.

## [Frontend Display](#frontend)

Take a look at the screenshot below to see how it could be displayed in your frontend.

![acf-php-frontend](https://www.tassos.gr/images/acf-php-frontend.png)

## [Examples](#examples)

Below you can find a list of PHP code examples.

#### [Simple message output](#simple-message-output)

 ```
return 'Hello World!';
```

#### [Variable usage](#variable-usage)

 ```
$name = 'John Doe';
return 'My name is: ' . $name;
```

#### [Accessing the user object](#accessing-the-user-object)

 ```
return 'User is ' . (($user->guest) ? 'a guest' : 'logged in');
```

#### [Accessing the field object](#accessing-the-field-object)

 ```
return 'The title of the field is: ' . $field->title;
```

#### [Accessing item's data](#accessing-item-s-data)

We call "Item" the element where the field is attached to. In most cases the "Item" is the article where the field is being rendered.

 ```
return 'The article title is : ' . $item->title;
```

## [Frequently Asked Questions](#faq)

### [How can I override the layout of "ACF - PHP" custom field?](#how-can-i-override-the-layout-of-acf-php-custom-field)

To override the "ACF - PHP" custom field, read here: [How to override the "ACF - PHP" custom field](https://www.tassos.gr/joomla-extensions/advanced-custom-fields/docs/how-to-create-an-alternative-layout-for-joomla-custom-fields#override_render_layout).

 PHP Field is available in Pro  Unlock this and dozens of other powerful features by upgrading to Advanced Custom Fields Pro.

 [ Unlock this feature ](https://www.tassos.gr/joomla-extensions/advanced-custom-fields/subscribe)

 Last updated on Jul 2nd 2025 08:07

## Schema

```json
{
    "@context": "https://schema.org",
    "@type": "BreadcrumbList",
    "itemListElement": [
        {
            "@type": "ListItem",
            "position": 1,
            "name": "Home",
            "item": "https://www.tassos.gr"
        },
        {
            "@type": "ListItem",
            "position": 2,
            "name": "Home",
            "item": "https://www.tassos.gr/docs"
        },
        {
            "@type": "ListItem",
            "position": 3,
            "name": "Advanced Custom Fields",
            "item": "https://www.tassos.gr/docs/advanced-custom-fields"
        },
        {
            "@type": "ListItem",
            "position": 4,
            "name": "Fields Types",
            "item": "https://www.tassos.gr/docs/advanced-custom-fields/fields"
        },
        {
            "@type": "ListItem",
            "position": 5,
            "name": "PHP Field",
            "item": "https://www.tassos.gr/docs/advanced-custom-fields/fields/php"
        }
    ]
}
```

```json
{
    "@context": "https://schema.org",
    "@type": "Article",
    "mainEntityOfPage": {
        "@type": "WebPage",
        "@id": "https://www.tassos.gr/docs/advanced-custom-fields/fields/php"
    },
    "headline": "PHP Field",
    "image": {
        "@type": "ImageObject",
        "url": "https://www.tassos.gr/"
    },
    "publisher": {
        "@type": "Organization",
        "name": "Tassos",
        "logo": {
            "@type": "ImageObject",
            "url": "https://www.tassos.gr/https://www.tassos.gr/media/brand/logo-text.png"
        }
    },
    "author": {
        "@type": "Person",
        "name": "Tassos Marinos",
        "url": "https://www.tassos.gr/docs/advanced-custom-fields/fields/php"
    },
    "datePublished": "2019-02-20T11:05:50+02:00",
    "dateCreated": "2019-02-20T11:05:50+02:00",
    "dateModified": "2025-07-02T08:59:27+03:00"
}
```

```json
{
    "@context": "https://schema.org",
    "@type": "FAQPage",
    "mainEntity": [
        {
            "@type": "Question",
            "name": "How can I override the layout of "ACF - PHP" custom field?",
            "acceptedAnswer": {
                "@type": "Answer",
                "text": "To override the "ACF - PHP" custom field, read here: How to override the "ACF - PHP" custom field."
            }
        }
    ]
}
```
