Last active
May 14, 2020 19:08
-
-
Save jesders/4266d54aac0f607596fa7f9a705307aa to your computer and use it in GitHub Desktop.
WordPress / Passing parameters to function call.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Steps to passing function to array | |
// 1. Make parameters to add to function | |
// 2. Set up function and pass parameter | |
// 3. Register function via add_action | |
// 4. Call do_action passing in the parameters needed | |
$array = array('1', '2', 3, 4); | |
function a_hooked_function($array) { | |
var_dump($array); | |
} | |
add_action('action_name', 'a_hooked_function'); | |
do_action('action_name', $array); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment