0

I'm currently trying to load a custom made admin page inside a thickbox. It's for creating new users with loads of extra custom data and none of the stuff I don't care about. Administrators can navigate to this page manually and outside of a thickbox and the user gets created fine. But displaying it inside a thickbox is proving to be very difficult.

The reason I need it displayed inside a thickbox is because it will automatically assign the new user to a custom post type I've made called 'office' when the new user is created via this thickbox.

I think it needs to make a remote request, however the request times out even when I increase the timeout argument to 30 seconds. At first I thought it was due to the fact I was submitting a remote request to get an admin page without authentication, so I tried getting the site homepage on the frontend and still got the same timeout error.

For those of you that prefer to read/edit my code elsewhere, you may do so via this link - http://www.writeurl.com/text/65akmve9a5ofi7vbr4k0/8qma3hz8r0g9lgae5usp/ci2ipat23le7u66zl9c, otherwise I have included the same code below.

# link to call action to load addNewUser thickbox
printf(
    '<a href="%s" class="button button-secondary thickbox addNewUser">%s</a>',
    get_admin_url(
        get_current_blog_id(),
        "admin-ajax.php?action=addNewUser&amp;width=640&amp;height=400"
    ),
    __('Add New User')
);

# action when link is clicked
function getAddUserAdminPage() {
    $newUserPage = wp_remote_get(
        add_query_arg(
            array(
                'page' => 'newUser',
                'postID' => get_the_ID()
            ),
            get_admin_url(
                get_current_blog_id(),
                'users.php'
            )
        )
    );
    echo is_wp_error($newUserPage) ? $newUserPage->get_error_message() : wp_remote_retrieve_body($newUserPage);
    die();
}
add_action('wp_ajax_addNewUser','getAddUserAdminPage');
  • 1
    Can't you just use Ajax load for this ? Loading the admin page inside a created div as a thickbox ? Or I'm misunderstanding your question xD ? – Mateusz Winnicki May 30 '14 at 10:43
  • 1
    Dagnamit! - Am I the only developer who forgets how to do computer? – Ben May 30 '14 at 11:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.