Init hook function to call other hook in function.php

perhaps running it on the user_register hook? add_action( ‘user_register’, ‘loadAfterUserRegistrationHook’ ); function loadAfterUserRegistrationHook(){ add_action( ‘user_meta_after_user_register’, ‘createNewPost’ ); } See: http://codex.wordpress.org/Plugin_API/Action_Reference/register_form

Why doesn’t global $wp_query not get hooked?

If you look at the Action Reference, you can see the order things happen. Note where init is, the query object doesn’t exist until the wp action. // … init └─ widgets_init register_sidebar wp_register_sidebar_widget wp_default_scripts wp_default_styles admin_bar_init add_admin_bar_menus wp_loaded parse_request send_headers parse_query pre_get_posts posts_selection wp // …

Best way to disable swap in Linux

Identify configured swap devices and files with cat /proc/swaps. Turn off all swap devices and files with swapoff -a. Remove any matching reference found in /etc/fstab. Optional: Destroy any swap devices or files found in step 1 to prevent their reuse. Due to your concerns about leaking sensitive information, you may wish to consider performing … Read more

Can i use init hook for API purpose?

If you want a more user-friendly URL structure, you could add a rewrite endpoint. This will add the rules for and intercept requests to /my-api/: function wpd_add_api_endpoint() { add_rewrite_endpoint( ‘my-api’, EP_ROOT ); } add_action( ‘init’, ‘wpd_add_api_endpoint’ ); function wpd_api_request( $request ){ if( isset( $request->query_vars[‘my-api’] ) ){ // $request->query_vars[‘my-api’] is a string containing everything after your … Read more

Init action and refresh page after form action

From the documentation: https://developer.wordpress.org/reference/hooks/init/ add_action( ‘init’, ‘process_post’ ); function process_post() { if( isset( $_POST[‘unique_hidden_field’] ) ) { // process $_POST data here } } In your example, perhaps having two different add_action is causing problems and burying your function where it’s not firing during init I’m going to test a similar solution and see what … Read more

How to do a task only once for logged in users

There are various ways to do this, but I’ve recently addressed a similar problem by using cookies. add_action( ‘init’, ‘wpse_93797_cookie’ ); function wpse_93797_cookie() { if ( !isset ( $_COOKIE[‘wpse_93797_cookie_name’] ) ) { // Do your stuff. // Set your cookie so we don’t do stuff the next time around. // Note that 0 makes the … Read more

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