• Trying to print out current user information with:

    $current_user = wp_get_current_user();
          print_r($current_user);
          print_r($current_user->user_login);

    But data comes emtpy:
    WP_User Object ( [data] => stdClass Object ( ) [ID] => 0 [caps] => Array ( ) [cap_key] => [roles] => Array ( ) [allcaps] => Array ( ) [filter] => )

    The custom role is a copy of a WP core role (subscriber).

    Do I need to add a new capability to view its properties?

    When I switch to any user role (using the user switch link), I can view the user data correctly.

    
    WP_User Object ( [data] => stdClass Object ( [ID] => 7 [user_login] => Usuario Propietario [user_pass] => $P$BW4jU7IBFInyniTZc1WGrEl7.L2pME1 [user_nicename] => usuario-propietario [user_email] => propietario@propietario.com [user_url] => [user_registered] => 2016-10-13 01:06:29 [user_activation_key] => [user_status] => 0 [display_name] => Propietario Propietario ) [ID] => 7 [caps] => Array ( [propietario] => 1 ) [cap_key] => wp_capabilities [roles] => Array ( [0] => propietario ) [allcaps] => Array ( [create_posts] => 1 [edit_pages] => 1 [edit_posts] => 1 [edit_private_pages] => 1 [edit_private_posts] => 1 [edit_published_pages] => 1 [edit_published_posts] => 1 [level_0] => 1 [level_1] => 1 [level_2] => 1 [level_3] => 1 [level_4] => 1 [level_5] => 1 [level_6] => 1 [level_7] => 1 [publish_pages] => 1 [publish_posts] => 1 [read] => 1 [read_private_pages] => 1 [read_private_posts] => 1 [unfiltered_html] => 1 [upload_files] => 1 [vc_access_rules_post_types/enhancedcategory] => 1 [propietario] => 1 ) [filter] => ) Usuario Propietario

    But when I log out and then log in with the aforementioned custom user role, data comes up empty.

    Any suggestions?

    Thanks.

    • This topic was modified 7 years, 5 months ago by mauferrusca. Reason: added new behaviour
Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter mauferrusca

    (@mauferrusca)

    Forgot to mention that wp_get_current_user() is working correctly with Admin user role.

    Plugin Author Vladimir Garagulya

    (@shinephp)

    [ID] => 0 value is shown e.g. for unlogged in users.

    Try to re-assign that custom role to the user: assign him some other role, update, assign this custom role back.

    Thread Starter mauferrusca

    (@mauferrusca)

    Thanks. Will try that. And thanks for correcting me about no values shown.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Custom User Role shows not values’ is closed to new replies.