wordpress add_action() issue in ajax call

You’re sending your AJAX request to the wrong place. Of course calling functions.php directly will get you undefined function errors, because the WordPress API isn’t loaded by functions.php ( it’s the other way round ). A car doesn’t make fuel go forward, fuel makes a car go forward, simply getting in the car won’t make … Read more

Create a post builder skin in a plugin

You cannot insert the do_action() inside the class like that, it’s gonna give you a fatal error. Instead you could use an array $skins to store all the skin functions (as closures), and the magic method _call() to call them: class skinclass { private $skins = array(); function __construct() { $this->skins = apply_filters( ‘add_skin’, $this->skins … Read more

How to allow Contributors to publish articles after approval

How can I make the contributor rank able to publish an article but have it then require the approval of an admin before it actually gets published to the website? The “Contributor” role already behaves that way: Contributor delete_posts edit_posts read https://codex.wordpress.org/Roles_and_Capabilities#Contributor As you see, that role lacks the publish_posts capability of the role just … Read more

update_option_{$option} not showing old value

You should use pre_update_option_{option_name} filter. Example:- function system_save_number( $new_value, $old_value ) { mail(‘[email protected]’,’here’,print_r($old_value ,true) . “\n\n” . print_r($new_value,true)); return $new_value; } function system_init_actions() { add_filter( ‘pre_update_option_system_number’, ‘system_save_number’, 10, 2 ); } add_action( ‘init’, ‘system_init_actions’ );

Set post tags using tag ID

For non-hierarchical terms (such as tags), you can pass either the term name or id. If you pass the id there is only one caveat: You must pass it as an integer, and it must be in an array. This is necessary because any non-array value passed will be converted to a string, which will … Read more