Saturday, May 21, 2016

WordPress get user data

In WordPress there are many users with different roles. A user may have a administrator role, author or any other roles from the standard roles defined by WordPress.

If you want to find out user role or user information such as name,ID etc you can use the following function.

<?php
 $user_info = get_userdata(1);
          echo 'Username: ' . $user_info->user_login . "\n";
          echo 'User roles: ' . implode(', ', $user_info->roles) . "\n";
          echo 'User ID: ' . $user_info->ID . "\n";
?>

The above will give you user's username, role and ID.

No comments:

Post a Comment

MS SQL : How to identify fragmentation in your indexes?

Almost all of us know what fragmentation in SQL indexes are and how it can affect the performance. For those who are new Index fragmentation...