• Resolved fychan66

    (@fychan66)


    Hi again!

    Still loving the plugin – and still extending it. I now have a custom Trigger, with a custom Carrier, and a custom Recipient, which all fire to generate an internal mail within the site by populating a DB table.

    This works perfectly if I use a merge tag as defined in the Trigger (such as {current_user_id}).

    But, if I use a global merge tag, they get inserted as blank – same as if I use a non-existent merge tag (like {not_the_current_user_id}).

    In my debug settings, I get the following:

    recipients	
    Array
    (
        [0] => Array
            (
                [type] => recipient_user_id
                [recipient] => 
            )
    
        [1] => Array
            (
                [type] => recipient_user_id
                [recipient] => 499
            )
    
        [2] => Array
            (
                [type] => recipient_user_id
                [recipient] => 
            )
    
    )

    The first & third values are global merge tags, that should be an array of IDs.

    Am I missing an option somewhere in my custom Carrier, or custom Trigger, somewhere to load in the global merge tags?

    Thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter fychan66

    (@fychan66)

    Resolved!

    Turns out it was an artefact of the PHP I was writing – because I was having to loop through DB tables to evaluate the global merge tags, I was using eval() to output the return values. Turns out the eval doesn’t quite work this way (as hinted by this comment, which is what gave me the final hint to track down the solution: https://www.php.net/manual/en/function.eval.php#124863).

    So, now I’m writing what I was eval’ing to a string, writing that to a file, then require_once()ing that file & everything works as expected.

    I’ll switch the file writing to a cron task, so it’s not overly thrashing the HDD.

    Plugin Author Kuba Mikita

    (@kubitomakita)

    Oh my, that’s an interesting case for sure!

    I’m not sure though it’s the best way to evaluate anything or caching in the file. You could’ve used simple global var or even wp_cache_* functions. This, however, depends on the use case.

    I’m glad you got it working anyway!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Global Merge Tags not being populated?’ is closed to new replies.