• Resolved kokoruz

    (@kokoruz)


    I discovered that terms that were linked to profiles that have been deleted still maintain their relationship. This causes the count to be off and when you sort by the term it displays profiles that are void of content because they no longer exist. Is there a plan to have the plugin remove the relationships if the user is deleted?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author shawfactor

    (@shawfactor)

    no plans to change this as whilst it would be possible for taxonomies that are only set for users (not shared ones), it would be complex. That being aid I can′t see why this would be cause a problem as you can′t directly query users by taxonomy.

    Sure you will get some post ids that don′t reference a current user if you plug those into WP_User_Query say using the include parameter the user_ids that reference deleted profiles will just be ignored.

    Can you give me an example of the code you are using?

    Thread Starter kokoruz

    (@kokoruz)

    <div class="row profile profile-list">
    <div class="col-sm-12">                        
    <?php
    $term_id = get_queried_object_id();
    $term = get_queried_object();
    $users = get_objects_in_term( $term_id, $term->taxonomy );
    $desc = $term->description;   
    echo '<p>' . $desc . '</p>';
    
    if ( !empty( $users ) ) {
    echo '<div class="row equal">';
    foreach ( $users as $user_id ) {    
    echo '<div class="col-sm-3 d-flex"><div class="card bg-dark"><div class="card-body">';
    $nicename = get_the_author_meta('user_nicename', $user_id);   
    $f_name = get_the_author_meta('first_name', $user_id);
    $l_name = get_the_author_meta('last_name', $user_id);
    $mobile = get_the_author_meta('cell_phone', $user_id); 
    $office_phone = get_the_author_meta('office_phone', $user_id);
    $office_ext = get_the_author_meta('office_ext', $user_id);
    $email_address = get_the_author_meta('user_email', $user_id);
    $google_plus = get_the_author_meta('googleplus', $user_id);
    $twitter = get_the_author_meta('twitter', $user_id);
    $facebook = get_the_author_meta('facebook', $user_id);
    $instagram = get_the_author_meta('instagram', $user_id);
    $linkedin = get_the_author_meta('linkedin', $user_id);
    $facebook = get_the_author_meta('facebook', $user_id);
    $youtube = get_the_author_meta('youtube', $user_id);
    echo '<img class="img-thumbnail" src="' . esc_url( get_avatar_url( $user_id, array("size"=>150) ) ) . '" />'; /*get_avatar_url*/
    $badge = get_field('user_profile_photo', 'user_' . $user_id);
    echo '<p><span class="label">Name:</span><span class="data">' . $f_name . ' ' . $l_name . '</span></p>';
    echo '<p><span class="label">Email:</span><span class="data"><a href="mailto:' . $email_address . '">' . $email_address . '</a></span></p>';
    
    if (!empty($mobile)) { echo '<p><span class="label">Cell Phone:</span><span class="data">' . $mobile . '</span></p>'; };
    if (!empty($office_phone) || !empty($office_ext)) { echo '<p><span class="label">Office Phone:</span><span class="data">' . $office_phone . ' x' . $office_ext . '</span></p>'; };
    if (!empty($google_plus)) { echo '<span class="data-icon"><a target="_blank" href="' . $google_plus . '"><i class="fab fa-google-plus-square"></i></a></span>'; };
    if (!empty($twitter)) { echo '<span class="data-icon"><a target="_blank" href="https://twitter.com/' . $twitter . '"><i class="fab fa-twitter"></i></a></span>'; };
    if (!empty($facebook)) { echo '<span class="data-icon"><a target="_blank" href="' . $facebook . '"><i class="fab fa-facebook-square"></i></a></span>'; };
    if (!empty($youtube)) { echo '<span class="data-icon"><a target="_blank" href="' . $youtube . '"><i class="fab fa-youtube"></i></a></span>'; };
    if (!empty($instagram)) { echo '<span class="data-icon"><a target="_blank" href="' . $instagram . '"><i class="fab fa-instagram"></i></a></span>'; };
    if (!empty($linkedin)) { echo '<span class="data-icon"><a target="_blank" href="' . $linkedin . '"><i class="fab fa-linkedin"></i></a></span>'; };
            
    echo '<div class="profile-btn"><a class="btn btn-light btn-sm" href="/profile-page/user/index.php?user=' . $nicename .'">View User Profile</a></div>';   
    echo '</div></div></div>';
    }
    echo '</div>'; ?>
    <?php } ?>
    </div>
    </div>
    Plugin Author shawfactor

    (@shawfactor)

    Ah that is not really a problem with my plugin.

    Pass the user_ids through to the the user ids through the get_users function as the include argument and then loop through the resulting users, more info here:

    https://codex.www.ads-software.com/Function_Reference/get_users

    code should be more efficient too.

    get_users will ignore any user_ids that point to a deleted user.

    Thread Starter kokoruz

    (@kokoruz)

    Related but not related but I’m hoping you can help. I am hoping to show taxonomy terms for just the role “resource” but it displays the taxonomy for every term that has been assigned to a user. I’ve tried wp_list_categories, get_terms and WP_Term_Query. I can’t find a way to only render the terms for a specific role. If you can provide some insight I would appreciate it. I did go back and rewrite my other content based on your get_users link. Thank you for that.

    <?php
    $service_terms_args = array(
        'taxonomy'      => 'service',
        'order'         => 'ASC',
        'orderby'       => 'name',
        'hide_empty'    => true,
        );
        $service_terms_query = new WP_Term_Query( $service_terms_args );
            if (!empty( $service_terms_query ) ) {
                echo '<p><span class="label">Services:</span><span class="data">';
                    if (!is_wp_error( $service_terms_query ) ) {
                        echo '<ul>';
                            foreach( $service_terms_query->get_terms() as $service_term ) {
                                echo '<li><a href="' . get_term_link( $service_term->slug, 'service' ) . '">' . esc_html( $service_term->name ) . '</a></li>'; 
                            } 
                        echo '</ul>';
                    }
            }
    ?>
    Plugin Author shawfactor

    (@shawfactor)

    Sorry I can′t follow what you mean. Roles are about user permisions. The built in ones are subscriber, contributor, author, editor. administrator etc.

    You can create custom roles but I′m not sure why you would create a custom role of ‘resource’.

    In any case you could not get the terms for a role, nor am I sure why you would want too.

    Plugin Author shawfactor

    (@shawfactor)

    I am closing this for good order, if there is an issue pleae open a new thread and explain the isue thoroughly

    • This reply was modified 5 years, 6 months ago by shawfactor.
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘term relationships’ is closed to new replies.