PHP

Redirect User after login - Drupal 8

When building sites, many client wants users to get redirected to particular page (like Site Home Page) or page based on User Roles. Today we'll see how we can redirect user after login to particular page.

NOTE: I've defined my own custom page using [MODULENAME].routing.yml named as "custom.redirect_callback", which we'll be using for redirecting user.

Alter $WP_Query in WordPress

When showing list of content (i.e. Posts, Custom Post Type) on Category Page, the main $WP_Query renders posts of default Posts type. To show content from different post type we've to alter the main $WP_Query.

There are few different ways using which we can alter the $WP_Query. But here is one of the way to alter $WP_Query without removing existing conditions in Query.

Drupal - Change label of exposed filter form button in views

Views one of the great module available in Drupal. Views can be used to show various types of dynamic data and can also be used to allow users to filter results based on his criteria. To allow users to filter results based on his criteria we normally use views "exposed filter" option in every filter we add in view (screenshot 1.0).

How to display PDF in browser via PHP

The last project I was working on was having a requirement hiding the file URL in browser, for security reason. The file was actually PDF file and was containing user's order data. So to restrict the access to PDF file I've created a page callback, where I've written small piece of code to show the PDF output directly in page. Here is the sample code: