0

When I go to edit a user's account located in:

http://web.site/wp-admin/user-edit.php?user_id=ID

I want to add a custom section with my own information (just text), similar to the add_settings_section() function. However, I believe this is limited to only adding custom sections to the Settings menu:

Settings
-- General
-- Reading
-- Media
-- Permalinks

This is what I have so far which adds my custom section in the Reading menu for testing purposes:

add_action( 'admin_init', 'wpse_edit_user' );
function wpse_edit_user() {
     add_settings_section( 'user_role', 'User Roles', 'wpse_user_role_section', 'reading' );
}
function wpse_user_role_section() {
    ?>
    <p class="description">Content to my custom section here...</p>
    <?php
}

But I do not want to located in Reading. How can I have my custom content display in the user-edit.php page?

1

Solved it by using show_user_profile and edit_user_profile instead:

add_action( 'show_user_profile', 'wpse_237901_user_edit_section', 999 );
add_action( 'edit_user_profile', 'wpse_237901_user_edit_section', 999 );

function wpse_237901_user_edit_section() {
    # Code here...
}

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.