From the course: WordPress: Action and Filter Hooks

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Using arguments to pass data

Using arguments to pass data - WordPress Tutorial

From the course: WordPress: Action and Filter Hooks

Start my 1-month free trial

Using arguments to pass data

- [Instructor] In programming terms, arguments are bits of information we can pass to a function. If we look at the syntax here for add_filter, we can see that the final parameter here is the accepted_args, and it defaults to one. So what this means is that by default, we can pass one argument to our callback function. If we look at the structure for add_action, it's the same thing. We've got a default value of one for our accepted arguments. Just like we saw with priorities, if you don't specify the number of arguments, it defaults to one. So let's go back to our call center example, and say that somewhere in our code, we've declared two variables, name and account number. When I'm using this add_action to hook my route_caller_to_agent function to the call_support_center hook, I have the default priority number of 10, and a default argument count of one. But let's say that I want my route_caller_to_agent function to have…

Contents