Help with filters
-
I’m having trouble with using the filters – I’m not that experienced with PHP so sorry if this is just a noob mistake.
Here is the code I’m using – it’s a basic regex function with arrays to allow multiple replacements:
add_filter( 'rwstripe_restricted_content_message', 'example_callback' ); function example_callback( $restricted_content_message ) { $patterns = array(); $patterns[0] = '/Purchase Access/'; $replacements = array(); $replacements[0] = 'Start your Subscription'; ksort($patterns); ksort($replacements); preg_replace($patterns, $replacements, $restricted_content_message); return $restricted_content_message; }
If I echo $restricted_content_message in the function then it prints with the correct replacement, but when I return it the replacement doesn’t work.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Help with filters’ is closed to new replies.