All posts by Gisha James

Some helpful information for writing a plugin

I am sharing 2 simple plugins I did, so it will be helpful for new plugin writers.

My client wanted to add an award section. That is, he wanted to assign an award for some post and display it in the front end under the title of the post. Each award has an image also.

So first he needs to create the awards. For that I wrote this plugin.

Now I have to display these awards when editing a post/ adding a new post.

For that I used the following plugin: Adding custom box

This plugin will save the award id as post meta. Later in the theme page we can call the post meta and display the award.

How to allow users to post only in some categories: wordpress

The following code will be useful if you want to allow users to post only in some categories.

function restrict_categories($categories) { 
// If we are in the new/edit post page and not an admin, then restrict the categories
$onPostPage = (strpos($_SERVER['PHP_SELF'], 'post.php') || strpos($_SERVER['PHP_SELF'], 'post-new.php'));
if (is_admin() && $onPostPage && !current_user_can('level_10')) {
$size = count($categories);
for ($i = 0; $i < $size; $i++) {			 			if ($categories[$i]->slug != 'user-created-articles' && $categories[$i]->slug != 'user-created-content' && $categories[$i]->slug != 'user-created-disagreements'&& $categories[$i]->slug != 'user-created-reviews')
return $categories;
add_filter('get_terms', 'restrict_categories');

In the above code it checks the category slug. Admin can post in any categories, but other users can post only in the categories, where slug is either “user-created-articles” or “user-created-articles” or “user-created-disagreements” or “user-created-reviews”

Permit contributors to upload images in wordpress

By adding the following code to functions.php in your theme file you can permit contributors to upload images.

if ( current_user_can('contributor') && !current_user_can('upload_files') )
	add_action('admin_init', 'allow_contributor_uploads');

function allow_contributor_uploads() {
	$contributor = get_role('contributor');

Domain name redirecting to /cgi-sys/defaultwebpage.cgi

For a client, in whm – cpanel after uploading all files to the root I got a confusing redirection which goes to /cgi-sys/defaultwebpage.cgi when I go to the domain name.

The page showed the message “Cpanel is successfully installed” etc…

Here is the solution to resolve the issue of redirection.

Edit httpd.conf . In the server there is Apache Configuration –> Include Editor –> post virtual host include

There write

<VirtualHost XXX.XX.XXX.XXX:80>
DocumentRoot /home/yourdom/public_html
UserDir disable

XXX.XX.XXX.XXX – should be replaced by your ip address.

yourdom – has to be replaced by your domain name.

Then restart Apache.

It should remove the redirection.

Javascript: Adding total depending on the selected checkbox

Example :

<form action="" method="post" name="form1" id="form1">
<input type="checkbox" name="install1" id="install1" onclick="calculate()" value="225" />

<input type="checkbox" name="install2" id="install2" onclick="calculate()" value="375" />

<input type="checkbox" name="package3" id="package3" onclick="calculate()" value="50" />

<input type="text" id="total" name="total"  size="6" />


Following is the javascript needed to calculate the total.

<script type="text/javascript">
function calculate() {
var elems = document.forms['form1'].elements;
var total = 0;
for(var i=0;i<elems.length;i++) {
if (elems[i].checked) {total += +(elems[i].value);}
elems['total'].value = total;

Integrating paypal to PHP website

While searching for paypal integration, I got this beautiful class from internet.

Thanks Micah Carrick, it is perfect for my work.

I am not explaining much about this integration because if you download it from the above link, it is well documented in the file.

So I don’t want to repeat it here.

Create a new Database in sql server 2005

Download and install SQL SERVER 2005  from

Download and install Microsoft SQL Server Management Studio Express from

Run SQL Server Management Studio Express. Right Click on Databases –> Create New Database

To create tables –> Click on the database name -> select Tables-> Right click –> Click on New Table

Installing IIS and WAMP on same computer

To run IIS and wamp server on the same computer all you need to do is to change the port address.

First, install IIS on your machine , start IIS manager, click on websites–>Right click on Default Websites  and select Properties —> Select Website –> TCP Port- enter port number, say 1025.  Now you can run IIS at http://localhost:1025/

Then install Wamp server, it will run on http://localhost/