• Resolved Rob W

    (@robertark)


    When using PHP functions that use PHP constants in the function, WP All Import throws an error.

    For example, this error: “Unexpected token TEXT” comes from when using:
    [str_pad({location_zip[1]}, 5, "0", STR_PAD_LEFT)]

    But if I change the constant to the integer value, it works fine. Eg:
    [str_pad({location_zip[1]}, 5, "0", 0)]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author WP All Import

    (@wpallimport)

    Hey @robertark,

    When using PHP functions that use PHP constants in the function, WP All Import throws an error.

    Unfortunately, that’s normal behavior due to how we parse PHP functions. You’ll have to write a custom function that uses the constant, then call that function instead. For example:

    [my_custom_function({location_zip[1]})]

    Code:

    function my_custom_function( $zip ) {
         return str_pad( $zip, 5, "0", STR_PAD_LEFT );
    }
    Plugin Author WP All Import

    (@wpallimport)

    Hi @robertark,

    I’m marking this as resolved since it’s been a while, but please let us know if you still have questions about this.

    Anyone else with questions, please open a new topic.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘PHP Constants cause errors’ is closed to new replies.