The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

creating a plugin - need help to get account info

Discussion in 'cPanel Developers' started by TheReliableHost, Mar 16, 2012.

  1. TheReliableHost

    Joined:
    Aug 5, 2008
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    India
    cPanel Access Level:
    Root Administrator
    Hello friends

    I am creating a plugin in PHP. I am almost done but to make it working fine I need to get two types of info..

    [1] Account username and email
    [2] Reseller username and email

    Well I know how to get account username
    Available cPanel Plugin Variables

    <cpanel print="$user">

    This is really easy but I cant find how can I get account email and reseller username and password. I am not expert in cPanel plugin programming. Just started working on PHP itself. Any detailed info and explanation will be great help to me.

    My plugin will be installed on end user cPanel account. and script will be installed naturally in Frontend /theme/ directory

    Regards
     
    #1 TheReliableHost, Mar 16, 2012
    Last edited: Mar 16, 2012
  2. KostonConsulting

    KostonConsulting Well-Known Member

    Joined:
    Jun 17, 2010
    Messages:
    255
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    San Francisco, CA
    cPanel Access Level:
    Root Administrator
    There's an undocumented API2 call used to display their contact email:

    Code:
    <?cp CustInfo::contactemails(%,value) ?>
    
    WARNING: This will display both their primary and secondary contact email if both are filled in.




    There are no exposed functions I'm aware of to get the reseller username or email. You can get the reseller username as the cPanel user if you tap directly into their Perl module Cpanel::AcctUtils::Owner and use the getowner() function.

    The reseller email is stored as the contact email for the reseller's cPanel account. It is not accessible from a customer account without privilege escalation and is also not exposed via the API.
     
  3. TheReliableHost

    Joined:
    Aug 5, 2008
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    India
    cPanel Access Level:
    Root Administrator
    Thanks a ton KostonConsulting. Is there any way I can get only primary or secondary email address?

    If I can get reseller username and email than it will be great feature to my script, What you told about perl module, I don't understand, Can you explain in detail please?
     
  4. KostonConsulting

    KostonConsulting Well-Known Member

    Joined:
    Jun 17, 2010
    Messages:
    255
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    San Francisco, CA
    cPanel Access Level:
    Root Administrator
    Unfortunately, API2 doesn't work like that. You can use Perl to get the email address with the Cpanel::ContactInfo::Email::getcontactemail() function.

    Here's a primer on Perl Modules: Learn Perl - How to Use Perl Modules

    In order to escalate privileges and get the email, you'll need to also use some C: Privilege Escalation with cPanel API Calls


    In general, PHP works well to write cPanel plugins when the features you need are available through their API. When those features are not available, using Perl allows you to access their code directly by loading up modules and can be the only way to accomplish certain tasks with cPanel.
     
Loading...

Share This Page