Crop image script

So you have a wordpress website and you have a form where user enters data, you have given an ‘upload image’ option but you want the uploaded images to be cropped for proper display ?
Below is the code that might help you crap crop it.

How to use it

Just paste the above code in functions.php file of your active wordpress theme. Then call the function wdw_crop_img passing proper parameters.

The above function out of the box is ‘wordpress specific’ because line no 23 in the code makes use of wordpress core function to get to the uploads directory (check line no 23, 25, 26 in the code). But you can obviously modifyl those 3 lines to suit to your website’s directory structure and make it work on any non-wordpress php website.

Rest, read the comment section above function declaration to figure out about the parameters passed and output.

Drop in your comment if you find any problem.
That’s it in here. Hope you find it useful.

Change wordpress registration email

The following code allows you to change the default email that wordpress sends after user registers on the website. You can modiy the default email and add your own custom email message and email subject.

The code:

*Add filter for registration email subject and message

function my_custom_registration_mail($email) {
    if (isset ($email['subject']) && substr_count($email['subject'],'Your username and password')>0 ) {
	if (isset($email['message'])) {

		$messg = "Hello,\r\nWe have received your sign-up request on our website. Your details are as follows:\r\n \r\n";
		$messg .= $email['message'];
		$messg .= "You can now login at the link given.\r\n \r\nWe look forward to your active participation on our website. \r\n \r\nkind regds,\r\nWebMaster \r\";
		$email['message'] = $messg;
		$email['subject'] = " - New Member Sign-up.";
    return ($email);

What to do with the code ?
Just add the code inside functions.php file of your current theme. And dont forget to change ‘’ to something useful 🙂

That’s it here. Hope you find it useful.

Add target blank to user link in recent comments widget

Open author link in new tab in wordpress default recent comments widget.

I just discovered it today itself on webdeveloeprswall. I’ve added a recent comments widget in my sidebar. The widget is a default wordpress widget, many of us use it. But when you click on the author link in the widget(sidebar) the commentor’s url (whatever he/she has provided) open in the same window!! Taking visitors away from your own website.

I immediately felt the need to add a target="_blank" attribute to those links. So here’s the small code snippet i came up with. Just add the below lines of code in your theme’s functions.php file:

function add_blank_get_comment_author_link($link){
	$rep_count = 1;
	$new_ret = str_replace("<a", "<a target='_blank'", $link, $rep_count);
	return $new_ret;
add_filter('get_comment_author_link', 'add_blank_get_comment_author_link', 10, 2);

and now the author links from recent comments open in new tab, hurray!! 🙂

Hope you find it useful. Cheers