How to add WordPress user using php code
Sometimes its necessary to create new user on WordPress site using PHP code. Below is code which will make this work
Sometimes its necessary to create new user on WordPress site using PHP code. Below is code which will make this work
Creating URL using PHP associative array
Extracting all links from text content
If you changed a post permalink and you want to let old one works fine, in your WordPress site .htaccess file add next line:
1 | redirect 301 /about http://example.com/about-me |
Where ‘/about’ is old relative URL and ‘http://example.com/about-me’ new URL
If its necessary pass to the function a lot of variables – its possible compact them into associative array by next function
If its necessary to clean all HTML tags and JS scripts from any content next PHP function will do the job
If we have associative PHP array and its necessary print it in JavaScript array, we ca use next PHP code:
1 2 3 4 5 6 7 8 | <script> <?php $any_array_keys = array_keys($any_associative_array); array_walk($any_array_keys, create_function('&$str', '$str = "\"$str\"";')); $any_array_keys= implode(',', $any_array_keys); ?> var woof_accept_array = ['min_price','orderby','woof_author',<?php echo $any_array_keys ?>]; </script> |
If its necessary to check is string we got is serialized array and unserialize it if its true
If its necessary, for example in any PHP loop (foreach) using any defined logic call specialized function with arguments by that logic – next code will do it:
1 | $json = call_user_func_array('json_encode', $args); |