Drupal: Write & Execute PHP code in blog post/forum content entry

This is a short but efficient trick that I found after making some stupid search queries 😦 In Drupal 6 & higher, you can type & execute PHP codes in your blog posts/ other contents. To do so, First enable the PHP Filter module from your Adminstration > Modules section:

php filter module

Enabling the PHP Filter module

Next, you can configure who must have access to execute PHP in their content. To grant only trusted users this permission, go to the Input Formats section (available under Administer » Site configuration)


Next, click on “configure” link next to the php code box.

How to write php in your posts

When creating a new blog/other entry, click on the “Input Format” just below the text editor. From the available options, select php code. See the screenshot below:

php in drupal

Hope this will be helpful!


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s