How do I display "Hello username" if logged-in on the homepage

I am trying to show the name of the currently logged-in user in a small text like 'Hello, username!'. I tried to do this, but it doesn't work: <p class="vam"> <?php if(is_user_logged_in()): $current_user = wp_get_current_user(); ?> Hello, <b><?php echo $current_user->display_name; ?></b>! <?php else:?> Hello, <span>Client</span>!`
Category: Web

Calling User Nickname

I am currently calling a user's nicename in a function I have: $users = $user_query->get_results(); foreach( $users as $user ): echo $user->user_nicename; I'm trying to call the user's Nickname instead, but nothing I do is working such as: echo $user->user_nickname; Is there a special way you have to call a user's nickname? Thanks
Category: Web

Why can't I update username through Wordpress API?

I'm just wondering about usernames... Why isn't is possible to change this through Wordpress API? (I understand why a user in the admin dashboard can't change username(s) but that isn't really same thing!?) Code below does just ignore the user_login - setting. $pupil_obj= get_post($postid_pupil); $user_login = $pupil_obj->post_name; $user_nicename = $pupil_obj->post_name; $user_args = array( 'ID' => $current_user->ID, 'user_email' => $email, 'user_login' => $user_login, 'user_nicename' => $user_nicename ); wp_update_user( $user_args ) ; I could update the username to the database directly through …
Category: Web

How to add @ symbol to user url

I want to add the @ symbol to the beginning of the username in the url i find this code to remove author from url But I do not know how I should change to add @ to the beginning of the usernames and the address will be @authorname or @nickname // The first part // add_filter('author_rewrite_rules', 'no_author_base_rewrite_rules'); function no_author_base_rewrite_rules($author_rewrite) { global $wpdb; $author_rewrite = array(); $authors = $wpdb->get_results("SELECT user_nicename AS nicename from $wpdb->users"); foreach($authors as $author) { $author_rewrite["({$author->nicename})/page/?([0-9]+)/?$"] = …
Category: Web

Redirect users with "." (dot) in their username and replace with "-" (dash) to correct profile

Im having problem with usernames that have '.' (dot) in their username and throwing 404 when try to access their profile page in front end. Can we replace this '.' (dot) with '-' (dash) because working url is with a '.'(dash). The system only generates link with user name ex: domain.com/members/[username automatically added] but some username includes '.' (dot) which system dont recognize. Ex: domain.com/members/user.name -> 404 domain.com/members/user-name -> working
Category: Web

Wordpress User Name Limitations

I need to know what the wp specifications for the usernames are. Like allowed minimum and maximum length, are special characters like ü,ö,ä,ß accepted,..? Unfortunately I couldn't find any insight on this in the interweb. Do you have any?
Category: Web

Register email as username

I am using Wordpress 4.9.4 in a Wordpress Multisite, and I need to allow users to register using their email address as username. Looking at the code I found that what prevents me from accomplish that is that in the ms-functions.php there is a regular expression filtering usernames that have other characters than a-z, so when an email is the username I would get "Usernames can only contain lowercase letters (a-z) and numbers." I changed that regular expression in the …
Category: Web

What are the best practices to achieve cross-domain interoperability and transparency in aggregate data through a uniform, hashed user naming schema?

The following plugin was just presented at the special session on data provenance to amend NSA's hard problems during the Hot Topics on Science of Security (HoTSoS) symposium. I'm looking for peer review regarding best practices prior to submission to the WordPress repository. It's fairly self-explanatory and a surprisingly simple way to achieve cross domain interoperability through the hashing of usernames. Other open source networks persist around this concept but Wordpress is a much larger medium with a potential for …
Category: Web

How to recover lost username?

I have a blog (www.ahsrocketlaunch.org) and need to update to the latest version of wordpress. However, I cannot remember the username I used to set up the wordpress account. therefore, I can't access the account to update WordPress. Is there any way to do this?
Category: Web

How to change a username?

How do I change a username? My username is showing up in search engines as an author but it's a product and services based site (using only pages) for a client. If I can't remove the author pages I need to change my username. It looks like you can change your username if you are on wordpress.com so that means it might be possible but this is a personal WP install.
Category: Web

Lock out all WordPress Administrators except two specific users

I used the snippet below to lock out all administrators and editors except myself if ( is_user_logged_in() ){ $current_user = wp_get_current_user() ; if ( in_array( 'administrator', (array) $current_user->roles ) || in_array( 'editor', (array) $current_user->roles )) { if ($current_user->user_login != 'sheila' ){ wp_logout(); return new WP_Error( 'login_again_please', 'Please log in again' ); } } } When I try to add a second user in the second if statement we are both locked out: if ( is_user_logged_in() ){ $current_user = wp_get_current_user() ; …
Category: Web

How to display user nickname (not display name) in PHP template?

I would like to display a nickname instead of username/display name on top of my website. I want to insert PHP codes which can display that Nickname in a PHP page. I have tried these codes below, but they don't work: ........some codes above................... <?php global $current_user; wp_get_current_user(); ?> {if is_user_logged_in()} <?php $nickname = $current_user->user_nickName; ?> <?php echo $nickname; ?> ..........some codes below......... But it works for username as below: ........some codes above................... <?php global $current_user; wp_get_current_user(); ?> {if is_user_logged_in()} …
Category: Web

Display a custom name when the user has no name settle in his account

I'm creating a code that shows the First Name for logged in users, using a shortcode, but I noticed that if the user has no name settle, it will display a blank space. How can I set a custom name to show up instead of the blank space? Something like this "Hi >No Name<, please settle your name in your account." Display first name: // show first name if logged in function colaborador_nome($atts) { if (is_user_logged_in() && !is_feed()) { return …
Category: Web

Display first name of logged in user?

I'm trying to create shortcodes that will display both avatar and logged in user first name in a text widget. I have managed to create something that displays the avatar, but not the username. My code is as follows: <?php // show user avatar if logged in function colaborator_avatar($atts) { if (is_user_logged_in() && !is_feed()) { return get_avatar(get_the_author_meta( 'user_email' )); } } add_shortcode('colaborator_avatar', 'colaborator_avatar'); // show user avatar if logged in /**/ function colaborator_nome($atts) { if (is_user_logged_in() && !is_feed()) { return …
Category: Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.