• Resolved judyoos

    (@judyoos)


    Snippets – did google myself blue

    Maybe s Stupid Question for some, but I will appreciate some advice.

    I have snippets that I created and placed in the “Code Snuppits” plugin.

    all of them use the same method just different function depending on the need:

    add_action(‘frm_display_form_action’, ‘check_user_count’, 1, 3);

    function check_user_count($params, $fields, $form){

    if($form->id == 34) {

    I have a display before each ADD_ACTION so I can see whats happening. Plus Displayes to see the values.

    I know in other programming languages you have an IF statement to and if true that code will execute.

    But with snippets it looks like the are running the whole time instead of just when I go into that specific page on the website….See error log image below, I am doing nothing on the system yet they run which in my opinion will cause issues.

    Do I Miss unerstand how to use them…..

    I did put priorities to each but they then just run in that sequence. I did a lot of googling just get examples not explaining my issues.

    Thanks in advance.

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter judyoos

    (@judyoos)

    Really bad to not even get a response….waiting so long for just a reply. how do one get one faster

    Plugin Author Shea Bunge

    (@bungeshea)

    Hi @judyoos,

    Please keep in mind that this is a free support forum, and I am more or less the only one to answer questions here. I did not check my email much yesterday as I was unwell, and regardless I would not consider one day a long time to wait for a response.

    I can’t seem to see the error log image that you refer to in your post.

    In the example you provide, the code up to and including the if statement check run on every page within the snippet scope. This is because the code needs to at least run in order to check whether it is currently on the correct form page. Once the if check has been performed, if the page is not the one specified in the condition, then the code within the if statement will not run.

    Thread Starter judyoos

    (@judyoos)

    Appologies and thanks for the reply. Is then ok if the Add_action AND function statement gets executed all the time…..but the if will stop the logic to happen which is fine.

    or do you think I must add a if page-id before the Action and function.

    Plugin Author Shea Bunge

    (@bungeshea)

    The way that you are checking for the current page means that it has to be done inside the function. There are some checks that can be done beforehand, but not all.

    It should be fine checking within the function itself; the impact on performance is negligible.

    Thread Starter judyoos

    (@judyoos)

    Thanks a lot I will then use it as is. Again I am sorry I was rude did not realize only one person did the free support.

    I thank you for that and your time.

    Thread Starter judyoos

    (@judyoos)

    Sorted

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Code in Snippets run the whole tine’ is closed to new replies.