Skip to main content

cpanel UAPI display Current User cPanel username

Comments

6 comments

  • cPanelTJ
    Hi @Jaro747, Thanks for the question! The "user" variable is returned in the output of the
    0
  • Jaro747
    Please can you correct me [CODE=php]$cpanel = new CPANEL(); // Connect to cPanel - only do this once. //Retrieve user settings for example.com. $variables = $cpanel->uapi( 'Variables', 'get_user_information', array( 'name' => 'username', ) ); echo "$variables";
    0
  • cPanelTJ
    Please can you correct me

    The variable is `user`, so 'name' => 'username',
    should be 'name' => 'user',
    instead. See below: [CODE=perl]$cpanel = new CPANEL(); // Connect to cPanel - only do this once. //Retrieve user settings for example.com. $variables = $cpanel->uapi( 'Variables', 'get_user_information', array( 'name' => 'user', ) ); echo "$variables";
    0
  • Jaro747
    I have create simple cpanel plugin with index.php file and code below [CODE=php] echo "testing" ; $cpanel = new CPANEL(); // Connect to cPanel - only do this once. //Retrieve user settings for example.com. $variables = $cpanel->uapi( 'Variables', 'get_user_information', array( 'name' => 'user', ) ); echo "$variables";
    Output testing is visible but no Current User cpanel username visible $variables can you tell me please what's wrong in this script
    0
  • Jaro747
    I put this code in the index.php plugin files and nothing works, I have a white screen :(
    0
  • cPanelTJ
    Hi @Jaro747 You have to be sure to traverse the tiers of data in the returned object. The return structure for this particular scenario is:
    • result
      • data
        • user
    The following code should work. [CODE=php]uapi( 'Variables', 'get_user_information', array( 'name' => 'user', ) ); print $variables['cpanelresult'>['result'>['data'>['user'>; ?>
    0

Please sign in to leave a comment.