Dog obedience schools are a prerequisite for
agility training for dogs. If you dog doesn't know how to stay or sit when told, the much more complicated agility obstacles will certainly puzzle him. You can ask for professional help at a local training school or just learn these techniques for yourself and ask for help when your are absolutely out of ideas that may work.
When you train your dog to do whatever you want him to do, you have to be firm and consistent. Pick one word, and one tone to tell him that you do not approve of his behavior. Endorse patterns that you want to see in your dog and don't respond to ones that you would like to get rid of.
To make your dog successfully complete agility courses you need to teach him how to follow your or stay in place. Whenever you command your dog to stay and he does, give him cookies or his favorite toy. Whenever he gets distracted or moves from his spot, you don't reward him.
Dogs learn new tricks and the expected behavior through repetition. To stop your dog from barking you have to be strict and firm about your opinion. Don't let him do what he wants to just because he barks.
Don't go there to pat him and argue with how you disapprove of barking. It would work with kids who understand the reasons, but dogs read your tone of voice and body language.
Pick a tone and a word and every time he barks, use that and don't let him in, out or give him whatever he wants. You are the boss, and he has to learn that to do well on agility competitions. The most effective ways to teach things to your dog is to lure, treat and reward. Dogs do just about anything you tell them to do if you reward them for the right actions and repeat it enough times.