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 Answer
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...
}

Leave a Reply

Your email address will not be published. Required fields are marked *