logged_in user outside of wordpress loop

this worked with root cookie: <?php define(‘WP_USE_THEMES’, false); if (file_exists(‘../books/wp-blog-header.php’)) { require_once(‘../books/wp-blog-header.php’); } else { echo ‘ERROR: blog header does not exist’; } global $current_user; get_currentuserinfo(); # Either load WordPress : http://codex.wordpress.org/Integrating_WordPress_with_Your_Website # or Manually define your url like… $cookieurl = “mybooksite.com”; define( ‘COOKIEHASH’, md5( $cookieurl ) ); $cookiename = “wordpress_logged_in_” . COOKIEHASH; $sitetitle=”Book Viewer”; … Read more

User count only for role frontend vendor

to get the number of authors who are assigned a particular role the get_users() function should do it: $args = array( ‘role’ => ‘frontend_vendor’,//substitute your role here as needed ‘fields’ => ‘ID’, ); $users = get_users( $args ); $user_count = count( $users );

How to disable users changing their display_name?

You can use jQuery to disable the display name select. function disable_display_name() { global $pagenow; if ( $pagenow == ‘profile.php’ ) { ?> <script> jQuery( document ).ready(function() { jQuery(‘#display_name’).prop(‘disabled’, ‘disabled’); }); </script> <?php } } add_action( ‘admin_head’, ‘disable_display_name’, 15 );

Get the author registration date in the header.php file

If you are using this on author pages or in loop then you can simply use this. echo the_author_meta( ‘user_registered’ ); This will output registration date of author. So your function will become. if ( is_author() ) { $curauth = ( isset($_GET[‘author_name’]) ) ? get_user_by( ‘slug’, $author_name ) : get_userdata( intval($author) ); $date = the_author_meta( … Read more

How to get only 1 role from user

Try this: if ( !empty( $user->roles ) && is_array( $user->roles ) ) { $first_role = array_shift($user->roles); echo $first_role; } Function array_shift obtains the first element of the $user->roles array.

Not able to call value in the core files

You’r following an bad idea. What you would like to reallize is, displaying a few profiles, not all. It doesn’t matter if the role is named “king” or “queen” even if your specific roles called so. There is an better way to reallize such Kind of requirements: Capabilities. Add an capabilitie to WordPress and just … Read more