WordPress sending emails continuously. How to stop it?

The problem I think the problem here is that you’re generating an infinite loop, by placing wp_mail() inside the $phpmailer->action_function callback, that fires after each email. Each time you send an email with wp_mail(), you call wp_mail() again, and again, and again … etc Possible workaround You should instead use, for example, the following approach: … Read more

Hide Theme options and Customize Admin menu

Direct answer: add_action( ‘admin_menu’, function() { global $current_user; $current_user = wp_get_current_user(); $user_name = $current_user->user_login; //check condition for the user means show menu for this user if(is_admin() && $user_name != ‘USERNAME’) { //We need this because the submenu’s link (key from the array too) will always be generated with the current SERVER_URI in mind. $customizer_url = … Read more

WordPress plugin for affiliate referral system

Don’t know about a plugin but this can be done easily with just two hooks and callback functions: First you add the refferer field to the registration form using register_form hook: add_action(‘register_form’,’show_reff_field’); function show_reff_field(){ ?> <input id=”ref” type=”text” tabindex=”20″ size=”25″ value= “<?php if (isset($_GET[‘ref’])){echo $_GET[‘ref’];} ?>” name=”ref” readonly=”readonly”/> <?php } Then you just need to … Read more

Hardcode a Plugin into theme

My first recommendation: Don’t do it! If the plug-in author releases an update, you can and will run into conflicts. Particularly if someone installs both the new plugin and your theme at the same time. A much safer route is to build plugin support into your theme. Make things degrade gracefully in case the plugin … Read more

add action wp_head not working

Pull the add_action() outside of the function, and put the conditional inside the callback. Also, if you’re printing a script directly, use wp_print_scripts instead of wp_head. You also have a syntax error. function testingone(){ if( get_option( ‘MyOptionName’ ) ) { ?> <script>var Script = GoesHere; </script> <?php } } add_action( ‘wp_print_scripts’,’testingone’ );