Why is user_can_access_admin_page() an undefined function?

As mentioned by Jacob Peattie: functions not loaded yet. You will need to use hooks/actions (init, wp etc) https://codex.wordpress.org/Plugin_API/Action_Reference e.g. function callMyMethod(){ $userLoggedIn = is_user_logged_in(); echo ‘INIT Action: User Logged in: ‘.var_export($userLoggedIn, true); if ( is_admin() ) { $canAccess = user_can_access_admin_page(); } } add_action(‘init’,’callMyMethod’); This answer is assuming you’re creating a plugin and calling the … Read more

Add another user role based on a defined input field in WordPress (Woocommerce)

Add the following code snippet to your WordPress theme’s functions.php file. Define the new user role and capabilities (you can customize this based on your needs) function add_custom_roles() { add_role( ‘corporate_customer’, ‘Corporate Customer’, array( ‘read’ => true, ‘edit_posts’ => true, ‘delete_posts’ => false, )); } add_action( ‘init’, ‘add_custom_roles’ ); A function to update the user … Read more

How to make my logged-in user-role shortcode displaying name instead of slug?

Based on what you wrote, you should use instead : if ( ! is_admin() ) { function get_user_role() { global $wp_roles; $user = wp_get_current_user(); $roles = ( array ) $user->roles; foreach ( $roles as $role ) { $user_role=”<p>” . $wp_roles->roles[ $role ][‘name’] . ‘</p>’; } return $user_role; } add_shortcode( ‘display_user_role’, ‘get_user_role’ ); } It works … Read more

techhipbettruvabetnorabahisbahis forumueduseduedueduseduedusedueduseduedus