0

Sorry if this is super "newbie", but I'm stumped. I'm trying to create a function in WP All Import that states if the cell is empty it populates with "Not Specified". Please see below:

function power_translate_data( $data ) {
    $map = array(
        ' '                     => 'Not Specified',
 );

    foreach ( $map as $partial_match => $mapped_value ) {
        if ( stristr( $data, $partial_match ) ) {
            return $mapped_value;
        }
    }
    return $data;
}

I appreciate any help you can give. Thank you!

2
  • stristr with ' ' will attemp to find the string value of a space in the data. You want to use if ( trim($data) == $partial_match ) and set the value to '' (no space) Commented Oct 10, 2019 at 9:03
  • @majick that worked beautifully. Thank you! Commented Oct 10, 2019 at 11:19

1 Answer 1

0
  • First enable wp_debug log
  • Second dump the array errror_log(print_r($map))

  • Then look at your data array, and then start out writing the function.

  • Sometimes WP All Import is a pain in the ass

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.