Answers for "check current user is admin wordpress"

PHP
2

wp is user admin

if ( current_user_can('administrator') ) {} // also others than admin w same capabilities
if ( is_user_admin() ){} // if it is admin
if ( is_admin() ){} //if the view is not the admin interface but the theme
Posted by: Guest on June-04-2021
1

how to check if user is logged in wordpress

<?php 
if ( is_user_logged_in() ) {
  echo 'Welcome, logged in user. <a href="'.wp_logout_url().'">Click here to logout</a>.';
}else{
  echo 'Please login by <a href="'.wp_login_url().'">clicking here</a>.'
}
Posted by: Guest on April-30-2021
0

How to Show the Logged in Username in the WordPress

function show_loggedin_function( $atts ) {

	global $current_user, $user_login;
	get_currentuserinfo();
	
	add_filter('widget_text', 'do_shortcode');
	if ($user_login) 
		return '<h4 class="logged-in-user">Hi ' . $current_user -> display_name . ' !</h4>';
	else
		return '<a href="' . wp_login_url() . ' ">Login</a>';
	
}
add_shortcode( 'show_loggedin_as', 'show_loggedin_function' );

//Shortcode
[show_loggedin_as]
Posted by: Guest on February-25-2022

Code answers related to "check current user is admin wordpress"

Browse Popular Code Answers by Language