• Resolved jared123

    (@jared123)


    Hi,

    I’m writing a theme with a built-in contact form processed via a script in the theme folder.

    I was wondering, is there a way to retrieve the currently set administrator email from the database so I can use it in my script? I know I could just add a theme admin page and make the user input an email address, but I’d rather keep it simple and access the admin email from the database.

    I tried searching the codex and googling, but got nowhere.

    Thanks in advance!

Viewing 4 replies - 1 through 4 (of 4 total)
  • haochi

    (@haochi)

    <?php
    $admin_email = $wpdb->get_var("SELECT user_email FROM $wpdb->users WHERE ID=1");
    ?>

    The $admin_email variable returns the email of user #1, which is normally the admin. It should work, but not tested.

    whooami

    (@whooami)

    how on earth are you writing a plugin if this was so elusive?

    http://codex.ww.wp.xz.cn/Function_Reference/get_userdata

    assume ID 1 is the admin account.

    Thread Starter jared123

    (@jared123)

    Thanks both of you, I appreciate it.

    And I’m not writing a plugin, I’m using it in a theme. And hey, I’m just learning! But thanks for the abuse! 😉

    Use

    get_bloginfo(‘admin_email’);

    It returns the administrator’s email as set in the database.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘retrieve administrator email from database?’ is closed to new replies.