Support » Plugins » Can add_action have a variable to represent it’s priority?

  • I’m writing a series of Plugins that use a similar call to place things in a theme. I would love for it to be possible to dynamically determine what priority they each have so that the end user from the admin area could adjust the order the plugins display. (so, if 3 plugins all displayed at the beginning of the loop, I would like it so that the user could determine the priority of each plugin so that they went in their desired order). I’ve tried placing a variable in the spot for priority in the add_action function, but WordPress gives an error if you do this. This seems like a major oversight in WordPress development if you can only supply a hard-coded number, since this priority value represents a huge capability for plugin authors.
    Am I missing something or am I out of luck?

Viewing 1 replies (of 1 total)
  • Moderator Samuel Wood (Otto)

    (@otto42) Admin

    You’re missing something. There’s nothing preventing you from using a variable for the priority of add_action. As long as the variable has a number in it, it works fine.

    $priority = 10;

    That should work fine.

Viewing 1 replies (of 1 total)
  • The topic ‘Can add_action have a variable to represent it’s priority?’ is closed to new replies.