Custom form action hook

admin_url( ‘admin-post.php’ ) is the non-ajax version of admin_url( ‘admin-ajax.php’ ) Similar to admin-ajax.php it will fire one of four hooks: Logged out users admin_post_nopriv_{action} ($_REQUEST[‘action’] specified) admin_post_nopriv (no $_REQUEST[‘action’] specified) Logged in user admin_post_{action} ($_REQUEST[‘action’] specified) admin_post (no $_REQUEST[‘action’] specified) The ‘action’ can therefer bespecified as part of the target url (e.g. admin_url( ‘admin-ajax.php?action=my-action’ … Read more

function ‘wp_enable_block_templates’ not found

Just to be sure, is “last WordPress version” the 5.8? wp_enable_block_templates is a function added in the version 5.8 of WordPress. You should find it in wp-includes/theme-templates.php as you can see here. Check if that function is actually present in your file. If not, probably something gone wrong during the updating. How did you do … Read more

Create hooks based on an array of hook names?

Your proposal is OK – you can see this in action even in the WordPress itself. See admin-ajax.php where you can find this piece of code: // Register core Ajax calls. if ( ! empty( $_GET[‘action’] ) && in_array( $_GET[‘action’], $core_actions_get ) ) add_action( ‘wp_ajax_’ . $_GET[‘action’], ‘wp_ajax_’ . str_replace( ‘-‘, ‘_’, $_GET[‘action’] ), 1 … Read more

Best possible way to get all options

I think it is always better to use the API, the functions of WP in this context. The function wp_load_alloptions() is under maintain and a custom select must always tested and maintain. Also the function use the Cache, if the installation support this. A good point for performance. The function supports also the Multisite installation, … Read more

Detect type of post status transition

If not, how do I tie multiple hooks to the same action? Do I just list them like so: add_action(‘new_to_publish’, ‘save_new_post’, 10, 1); add_action(‘future_to_publish’, ‘save_new_post’, 10, 1); add_action(‘draft_to_publish’, ‘save_new_post’, 10, 1); This is exactly the way to go. Just hook the same callback into each of the status-transition hooks on which you want the callback … Read more

add_action on inherit post status

I’m running into this same issue in some code I’m developing. In your case though tree is a better hook as you only want to hook posts that are moving to ‘publish’ You need to hook your function into all of the possible {status}_to_publish hooks like this: add_action(‘new_to_publish’, ‘my_function’); add_action(‘draft_to_publish’, ‘my_function’); add_action(‘auto-draft_to_publish’, ‘my_function’); add_action(‘pending_to_publish’, ‘my_function’); … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)