could not create directory during wordpress plugin install

It is sometimes a big challenge for most of the wordpress developers or admins to update the plugins or themes or the core wordpress version of their site.

There are many forums and discussion threads out there, that address this issue, and most of the solutions do not work for everyone. Here i am listing a solution that worked for me when trying to update plugins of a wordpress site, for which i have root access.

Note that you either need to setup ftp server for your wordpress site and configure its credentials in the wp-config.php file, or enable proper permissions for the folders inside wp-content and ensure apache user ownership on them.

Method 1:

  • Login as root to your wordpress server.
  • Check that vsftpd (ftp server) is installed and running.
  • Configure the ftp user credentials on the server
  • Open wp-config.php file and mention the ftp settings:
  • Method 2:

  • Ensure that the directories inside wp-content have 755 permissions set. This can be achieved by running the following commands from putty, navigating to wp-content folder:
  • Ensure that the apache user has proper ownership of the directories inside wp-content.
    This can be achieved by running the following commands from putty, navigating to wp-content folder:
  • You may also need to include the below line in wp-config.php file:
  • So i have tried both the above methods and they worked for me. Hope it helps someone in the future.

    FacebookTwitterGoogle+LinkedInEmailShare

    php pdo mysql example

    Connecting to a mysql database through the standard mysql_connect() function and querying the database with mysql_query() statements is not recommended any more. It is prone to sql injections. Hence the better way to connect to a database and query the results is through the PDO extension of php.
    The advantage of PDO is that it can connect to a major variety of database drivers, not just mysql. Also it can escape the user input with the help of prepared statements.

    Here is a Reference.

    FacebookTwitterGoogle+LinkedInEmailShare

    wordpress include custom files

    FacebookTwitterGoogle+LinkedInEmailShare

    wordpress add custom form in a page

    Have you ever wished to include a custom form inside a page of your wordpress site ?
    Well, its pretty simple.

    In this tutorial, we will try to include a small contact form in a page, that when submitted, sends out an email to the administrator of the site. The form contains 2 fields, address and phone number, which are filled by the end user.

    To proceed, create or edit a page in your site, and add the below form code to it. Assuming that jquery support is available for your site.

    Now create a new page in your backend, that maps to a custom php template file. Make sure that the slug for the page is same as the one defined as the action for our form (custom_contact_form).
    The idea is that, when the form in the page is submitted, it will be processed by our custom php template page.

    Below is the sample code of the custom php template file, that parses the form fields and sends out an email to the site admin:

    Done :)

    FacebookTwitterGoogle+LinkedInEmailShare

    drupal 7 ajax custom javascript

    In Drupal 7, we can pass the values from response object to a custom javascript function, after an ajax call is successfully executed.
    For an example, lets consider that there are two dropdown fields and the values of second dropdown are dependent on the selected value of the first dropdown.

    When an onchange event occurs on the first dropdown, we reload the second dropdown field, using the value from the first dropdown.

    Module file code:

    As you can see in the above function, we are passing the values of the selected first field, and the options of the second field, to the javascript function. Now we can access these values from the javascript callback function, that we define in the JS file:

    FacebookTwitterGoogle+LinkedInEmailShare

    Node hooks in Drupal

    We have several hooks for nodes in Drupal. Here i will discuss few of the hooks that can be used with view, add/edit and delete of the node.

    FacebookTwitterGoogle+LinkedInEmailShare

    Altering forms in drupal

    In Drupal, we can alter the forms of content creation, using the hooks: hook_form_alter(), and hook_form_form_id_alter().

    Normally, if you know the ID of the form that you want to alter, you can use hook_form_form_id_alter().
    Or you can use the generic hook_form_alter() and check if the page contains the form that you actually want to alter.

    Examples of usage:
    Suppose you have an “employee” content type and you want to customize the fields of the form (add/edit). You can use any of the below hooks in your module file:

    FacebookTwitterGoogle+LinkedInEmailShare

    Recommended directory structure for drupal modules

    In Drupal, we can classify the modules as 3 types:

    1. Core modules
    2. Contributed modules
    3. Custom modules

    Below are the recommended locations for storing the modules:

    Core modules:

    Contributed modules:

    Custom modules:

    The above approach will be useful when you upgrade Drupal or any of its modules to a new version.

    FacebookTwitterGoogle+LinkedInEmailShare