The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

Can add_action have a variable to represent it's priority? (2 posts)

  1. harknell
    Posted 9 years ago #

    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?

  2. 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.

Topic Closed

This topic has been closed to new replies.

About this Topic