function cjtheme_replace_user_menus($args = '')
{
    global $wpdb, $current_user;
    $user_role = cjtheme_user_role($current_user->ID);
    $cjtheme_role_menus = cjtheme_get_option('cjtheme_role_menus');
    if (isset($cjtheme_role_menus[$user_role]) && $cjtheme_role_menus[$user_role]['menu_location'] != '') {
        if ($args['theme_location'] == $cjtheme_role_menus[$user_role]['menu_location']) {
            $args['menu'] = $cjtheme_role_menus[$user_role]['menu'];
        }
    }
    return $args;
}
function cjtheme_user_role_display($user_id, $icon = null)
{
    global $wpdb;
    $table_custom_roles = $wpdb->prefix . 'gamf_custom_roles';
    $table_user_points = $wpdb->prefix . 'gamf_user_points';
    $modify_roles_query = $wpdb->get_results("SELECT * FROM {$table_custom_roles} ORDER BY points ASC");
    $user_points = $wpdb->get_row("SELECT SUM(points) as points FROM {$table_user_points} WHERE user_id = '{$user_id}'");
    $user_points = $user_points->points + 1;
    $role_points = $wpdb->get_row("SELECT * FROM {$table_custom_roles} WHERE points <= '{$user_points}' ORDER BY points DESC");
    $current_user_role = get_user_meta($user_id, 'cjtheme_user_role', true);
    if ($current_user_role != $role_points->role_display_name) {
        update_user_meta($user_id, 'cjtheme_user_role', $role_points->role_display_name);
        $nmessage = 'Your role is upgraded to ' . strtoupper($role_points->role_display_name);
        cjtheme_notification_add($user_id, $nmessage);
    }
    return '<span class="role">' . $icon . $role_points->role_display_name . '</span>';
    if (in_array(cjtheme_user_role($user_id), $modify_roles)) {
        return '<span class="role">' . $icon . cjtheme_user_role($user_id) . '</span>';
    }
}
function cjtheme_user_info($input, $var = null)
{
    global $wpdb;
    $user = $wpdb->get_row("SELECT * FROM {$wpdb->users} WHERE user_login = '******' OR user_email = '{$input}' OR ID = '{$input}'");
    $user_data_keys = array('user_login', 'user_pass', 'user_nicename', 'user_email', 'user_url', 'display_name');
    if (!empty($user)) {
        foreach ($user as $key => $value) {
            $users_data[$key] = $value;
        }
        $usermeta = $wpdb->get_results("SELECT * FROM {$wpdb->usermeta} WHERE user_id = '{$user->ID}'");
        foreach ($usermeta as $key => $value) {
            if (!in_array($value->meta_key, $user_data_keys)) {
                $users_data[$value->meta_key] = $value->meta_value;
            }
        }
        if (!is_null($var)) {
            $return_user_data = isset($users_data[$var]) ? $users_data[$var] : null;
            return $return_user_data;
        } else {
            $return_user_data = @$users_data;
            foreach ($return_user_data as $ukey => $uvalue) {
                if (is_serialized($uvalue)) {
                    $return_user_data[$ukey] = unserialize($uvalue);
                } else {
                    $return_user_data[$ukey] = $uvalue;
                }
            }
            $return_user_data['user_role'] = cjtheme_user_role($return_user_data['ID']);
            return $return_user_data;
        }
    } else {
        return null;
    }
}
function cjtheme_disable_wp_admin_bar()
{
    global $wpdb, $current_user;
    $disable_admin_bar_for_roles = cjtheme_get_option('wp_adminbar_roles');
    $current_user_role = cjtheme_user_role($current_user->ID);
    if (is_array($disable_admin_bar_for_roles) && in_array($current_user_role, $disable_admin_bar_for_roles)) {
        add_filter('show_admin_bar', '__return_false');
    }
}