Sunday, February 19, 2012

Add a login form on WordPress Theme

Add a login form on WordPress Theme

To display a login form just paste the following code on where you will like to display the wordpress login form. Like in sidebar or ant page template

<?php if (!(current_user_can('level_0'))){ ?>
<h2>Login Here</h2>
<form action="<?php echo get_option('home'); ?>/wp-login.php" method="post">
<input type="text" name="log" id="log" value="<?php echo wp_specialchars(stripslashes($user_login), 1) ?>" size="20" />
<input type="password" name="pwd" id="pwd" size="20" />
<input type="submit" name="submit" value="Send" class="button" />
       <label for="rememberme"><input name="rememberme" id="rememberme" type="checkbox" checked="checked" value="forever" /> Remember me</label>
       <input type="hidden" name="redirect_to" value="<?php echo $_SERVER['REQUEST_URI']; ?>" />
<a href="<?php echo get_option('home'); ?>/wp-login.php?action=lostpassword">Recover password</a>
<?php } else { ?>
<a href="<?php echo wp_logout_url(urlencode($_SERVER['REQUEST_URI'])); ?>">logout</a><br />
<a href="">admin</a>
<?php }?>

Saturday, February 18, 2012

Create thumbnail images using PHP

How to Create thumbnail images using PHP

By the following code you can understand how to create a thumbnail of a image

To create a thumbnail, we read in the file using the imagecreatefromjpeg() function and calculate the new thumbnail size. imagesx() and imagesy() functions return the width and height of the image respectively. Then we create a new image using the imagecreatetruecolor(). and Finally, we copy and resize the original file with the imagecopyresized() function and save thumbnail with imagejpeg()

$thumbWidth=70; // fix your widht
// get old widht and height
// calculate new widht and height;
$new_width = $thumbWidth;
$new_height = floor( $old_h * ( $thumbWidth / $old_w ) );
$tmp_image=imagecreatetruecolor($new_width,$new_height); // craete tmp images
imagecopyresampled( $tmp_image,$src_img, 0, 0, 0, 0, $new_width, $new_height, $old_w, $old_h);
imagejpeg( $tmp_image, "abc.jpeg" ); // get  the image and name it as abc.jpeg
imagedestroy( $tmp_image );

This process  can support for png and gif also

Extra contact methods to user profiles in wordpress

How to Add extra contact methods to user profiles in Wordpress

The following simple way you can do this , For this Paste the following code into function.php fille and then edit the line 4 and 5 as require.

add_filter('user_othercontactmethods', 'my_user_othercontactmethods');

function my_user_othercontactmethods($user_othercontactmethods){
  $user_othercontactmethods['facebook'] = 'Facebook Username';
  $user_othercontactmethods['twitter'] = 'Twitter Username';

  return $user_othercontactmethods;

I just got my #domain @BigRock. Get upto 25% off with my personalized coupon link Get upto 25% off