/** * Output the metabox used to view relationships * * @param object $user */ function wp_user_parents_metabox($user = false) { // Bail if no rental if (empty($user)) { return; } // Get user IDs $parent_ids = wp_get_user_parents($user->ID); $child_ids = wp_get_user_children($user->ID); ?> <table class="form-table"> <?php // Start an output buffer ob_start(); // Parents row wp_user_profiles_do_row(array('user' => $user, 'type' => 'parents', 'parent_ids' => $parent_ids, 'child_ids' => $child_ids)); // Children row wp_user_profiles_do_row(array('user' => $user, 'type' => 'children', 'parent_ids' => $parent_ids, 'child_ids' => $child_ids)); // Get the rows $rows = ob_get_clean(); // Output rows, or message why there are no rows if (!empty($rows)) { echo $rows; } else { ?> <tr><td colspan="2"><?php esc_html_e('This account currently has no available relationship options.', 'wp-user-parents'); ?> </td></tr><?php } ?> </table> <?php }
/** * Check if a user is a parent of another user * * @since 0.1.0 * * @param int $parent * @param int $child * * @return bool */ function wp_is_user_parent_of_user($parent = 0, $child = 0) { $parents = wp_get_user_parents($child); $is_parent = in_array($parent, $parents, true); return apply_filters('wp_is_user_parent_of_user', $is_parent, $parent, $child); }