Auto copy value from specific user meta field to another field

You can simply hook function to sync phone number field as following; <?php // HOOK ON REGISTERING NEW USER/CUSTOMER add_action(‘user_register’, ‘mm_sync_phone_number’ , 20, 1); // HOOK ON PERSONAL OPTIONS UPDATE add_action(‘personal_options_update’, ‘mm_sync_phone_number’ , 20, 1); // HOOK ON USER PROFILE UPDATE add_action(‘edit_user_profile_update’,’mm_sync_phone_number’ , 20, 1); function mm_sync_phone_number( $user_id ) { // GET PHONE NUMBER FROM … Read more

How to use `foreach()` in ajax call

I see that you found the error in the comments given to you on the post, and that is good. However, it should be pointed out that your code contains both an SQL Injection vulnerability, as well as a Reflected XSS vulnerability. $catId = $_POST[‘key’]; // value from the ajax … $result_fromDB = $wpdb->get_results(“SELECT * … Read more

Button click counter for login user

The First Problem The cause of this is not a WP problem, but a fundamental misunderstanding of how HTML forms work. To be specific, the problem is here: if( isset($_POST[‘clicks’]) ) { There is no input named clicks, so this value is never set ( because you never set it ). Lets look at your … Read more

Only display table in the_content() in canonical page

You can try this. Let put the following code at the end of file functions.php on the theme or child theme. add_action(‘wp_head’, ‘custom_show_table_on_download_page’, 20); function custom_show_table_on_download_page() { if(is_single()){ echo ‘<style type=”text/css”>.dpage {display: none !important;}</style>’; } }