I need to create a page for team coach's to view player data from a custom post type. Players are assigned to a "team" using a custom taxonomy called "team"

I have checkboxes setup for custom user meta which is dynamically populated by a custom taxonomy called "teams".

I need to display all checked options from the user's profile on a page with links to their corresponding taxonomy pages.


[X] Team A

[X] Team B

[ ] Team C

[X] Team D

On the page it will then display the team Names (Ex. Team A) and permalink to each team if they are checked in the user's profile.

How can this be achieved?

Function to create and save Custom User Meta Fields from Taxonomy

function coach_team_access( $user ) {
    $teams = get_terms('team', array('hide_empty' => false));
    $user_teams = get_the_author_meta( 'user_teams', $user->ID );
    <table class="form-table">
            <th>Team Access:</th>
        if ( count( $teams ) ) {
            foreach( $teams as $team ) { ?>
            <p><label for="user_iteams_<?php echo esc_attr( $team->slug); ?>">
                    id="user_teams_<?php echo esc_attr( $team->slug); ?>"
                    name="user_teams[<?php echo esc_attr( $team->term_id ); ?>]"
                    value="<?php echo esc_attr( $team->term_id ); ?>"
                    <?php if ( in_array( $team->term_id, $user_teams ) ) echo ' checked="checked"'; ?> />
                <?php echo esc_html($team->name); ?>
        } ?>
add_action( 'show_user_profile', 'coach_team_access' );
add_action( 'edit_user_profile', 'coach_team_access' );

    // store access
    function coach_team_access_save( $user_id ) {
        if ( !current_user_can( 'edit_user', $user_id ) )
            return false;
        update_user_meta( $user_id, 'user_teams', $_POST['user_teams'] );
    add_action( 'personal_options_update', 'coach_team_access_save' );
    add_action( 'edit_user_profile_update', 'coach_team_access_save' );

1 Answer 1


Create your blank admin page that will house this info, using add_menu_page() or add_submenu_page().

get your all the teams with get_terms() for later

get all players with get_posts(), and make a foreach() loop

within the loop, use wp_get_post_terms() to retrieve that players terms,

use the get_terms() value made earlier to loop through the list of teams.

add if statement to see if current player's has this term, then useget_term_link() to hyperlink, and mark it as checked

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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