How to list all registered users on your wordpress site

In my latest project i was required to add a community touch to a site by listing the Name, Email, Nickname, URI and Gravatar of all the registered users on the site. I came with the following solution : I made a new page template called users and added the following lines of php to the template :

<?php
/*
        First we set how we’ll want to sort the user list.
        * ID – User ID number.
        * user_login – User Login name.
        * user_nicename – User Nice name ( nice version of login name ).
        * user_email – User Email Address.
        * user_url – User Website URL.
        * user_registered – User Registration date.
*/

$sort= "user_registered";

//the default avatar to display in case gravatar is not available for a user
$default = "http://www.somewhere.com/some-directory/some-image.png";

//the size of the gravatar , here 96px
$size = 96;

//Build the custom database query to fetch all user IDs
$all_users_id = $wpdb->get_col( $wpdb->prepare(
        "SELECT $wpdb->users.ID FROM $wpdb->users ORDER BY %s ASC"
        , $sort ));

//we got all the IDs, now loop through them to get individual IDs
foreach ( $all_users_id as $i_users_id ) :

// get user info by calling get_userdata() on each id
$user = get_userdata( $i_users_id );

//GETTING INFO FROM EACH USERS
//get the user’s email ID
$email = $user->user_email;

//build the gravatar URL
$grav_url = "http://www.gravatar.com/avatar.php?
gravatar_id="
.md5( strtolower($email) ).
"&default=".urlencode($default).
"&size=".$size;

//get the user’s full name
$user_fullname=$user->first_name . ‘ ‘ . $user->last_name;

//get the user’s URI
$user_url=$user->user_url;

//get the user’s nickname
$user_nickname=$user->nickname;

//get the user’s description ( the biographical info field, )
$user_profile=$user->description;

?>

<!– Now here you can display each users info using the variables defined above –>

<?php
endforeach; // end the users loop.
?>

Hope you found it useful, cheers :) , WORDPRESS ROCKS

Setup your own apache sever with php and mysql, the easiest way using XAMPP

Many php developers find it difficult to test and debug their php scripts on their web host’s server, as it consumes much needed time, but what if you had your own PC turned into an apche server with the latest version of php and mySql? Manual installation of apache and php and their configuration to meet your needs is not an easy task, but with Apache Friends XAMPP , the task becomes as simple as installing a software or extracting a zip archive! XAMPP is an easy to install Apache distribution containing MySQL, PHP and Perl. XAMPP is really very easy to install and to use – just download, extract and start. .

XAMPP (current version 1.7.1 ) includes :

  1. Apache HTTPD 2.2.11
  2. MySQL 5.1.33
  3. PHP 5.2.9
  4. Openssl 0.9.8i
  5. phpMyAdmin 3.1.3.1
  6. Webalizer 2.01-10
  7. FileZilla FTP Server 0.9.31
  8. SQLite 2.8.15
  9. Zend Optimizer 3.3.0
  10. Mercury Mail Transport System v4.62

How to install?

XAMPP currently comes in 3 variations :

Installer : as simple as installing a software

ZIP Archive: just extract and use

Self-extracting ZIP archive

The choice is yours, i downloaded Self-extracting ZIP archive as it is very small in size and convenient to install.

Using the Self-extracting ZIP archive, extract all the contents to a top level directory in your hard drive, eg: C:/xampp

Now to manage your Apache and mySql services, open the XAMPP control Panel located at xampp/xampp-control.exe . Click on “start” button next to Apache to start your server, now open your browser and go to http://localhost/ , you should now see the XAMPP splash screen , that means your server is now working fine and you are all ready to run your php code on your PC. To run your php scripts, place all your files in xampp/htdocs directory and then call http://localhost/yourscript.php where yourscript.php is the name of your file.

Default passwords

The default user for mysql is root and password is “” , that means no password

So connect to the databse using php you can use mysql_connect("localhost","root","");

you can also change your mySql username and password here is how

Installing Wordpress using XAMPP

You can even set up a fully functional “local” wordpress blog on your PC, you can use it to test and debug your wordpress themes and plugins in live. To get started, download wordpress and place the wordpress directory in xampp/htdocs

folder, now go to http://localhost/wordpress/ where wordpress is your wordpress blog directory and follow onscreen instructions

But before going further, you will have to manually create a database in mySql for your wordpress blog, to create a new database go to http://localhost/phpmyadmin/ and create a new database with thw name of your choice,
now back to wordpress installation, enter the name of the database you just created in the database field, for usename enter “root” and leave the password field blank and submit. If everything goes fine, you will now be prompted for a title for you blog. Hooray!
your local wordpress blog is now ready, copy the password generated and login to the admin area, happy “local” blogging :) .

Installing XAMPP on your USB stick

Now this is the best part of XAMPP, you can even install XAMPP right on your USB drive! It can come really useful in situations like when you have to demonstrate to your client a site that uses php and mySql
on his PC. to install XAMPP on your USB drive, simply extract XAMPP to your USB stick instead of your hard drive and enjoy!

How to display a notice to your ie6 users using only css

This is year 2009 and not 1999, it is now time to move a step forward and shun internet explorer 6. Instead of trying to make your site work in internet explorer 6 and waste your precious time you should now consider to politely ask your ie6 visitor to upgrade. There are many ways to do so, but the simplest one i could come up with was using a css hack to display a particular div in ie6 and hide it in other browsers. The trick is to use ie6’s interpretation of _display as display .

Here is the code :

// CSS

#ie6_only {
//Hide it from good browsers
display:none;

//only ie6 will interpret it as display! others wont
_display:block;
}

// XHTML
<div id="ie6_only">
Your notice to ie 6 users here
</div>

Thats all! quite simple, isnt it? much simpler than using javascript or php to detect the browser and take action accordingly.

However you should position the div at such a place and in such a way that it is clearly visible.

You must also be polite in your notice and here is one example :

Dear visitor!

You are using an outdated browser that is not compatible with web standards,

You must consider upgrading to a different browser or a newer version of Internet Explorer to improve your web experience and enhance your online security and privacy
ThankYou

Further, you may consider becoming a supporter of NET magazine’s anti-ie6 campaign at http://www.bringdownie6.com

Wordpress Commercial Theme directory goes live…

The Official Wordpress Commercial Theme Directory has gone live today. The direcory is a part of the extend>themes section of wordpress.org. Though it is called “directory” right now it only lists some sites that provide commercial or premium wordpress themes licenced under our favorite GPL licence . The criteria for your site being included is quite simple.

To be included, you should:

* Distribute 100% GPL themes, including artwork and CSS.
* Have professional support options, and optionally customization.
* Your site should be complete, well-designed, up to date, and professional looking.
* Include a haiku about yourself to be included.

and send your details to themes@wordpress.com
Lets hope that they evolve further and start hosting commercial GPL themes themselves,

Scrap It – HTML scraps creator for Orkut

Scrap It is a simple light weight tool for quickly creating richly formatted cool looking scraps for Orkut. So if you are on Orkut and want to send your special friend a special scrap then just point your browser to http://www.dynamicguru.com/scrapit/ and enter your scrap in the form and hit submit, copy the code below the html template of your choice and paste in your friend’s scrapbook. Scrap It currently features only 6 templates, but stay tuned, more of them are on the way…:)

© 2010 Dynamic Guru All rights reserved — About UsContactMujtaba