Monthly Archives: March 2015

Send bulk email to users

Description:

Create admin tab menu(Bulk email) and submenu (Users list) in backend.

Bulk email tab: You can send email all of users with custom Mail Title and Mail Body.

Users list tab: Fetch all users email address from database table.

 functions.php


/* Register admin main menu and submenu */
add_action('admin_menu', 'my_menu_pages');
function my_menu_pages(){
add_menu_page('None Members', 'None Members', 'manage_options', 'none-member', 'my_menu_output' );
add_submenu_page('none-member', 'Send bulk email', 'Send bulk email', 'manage_options', 'none-member' );
add_submenu_page('none-member', 'Members list', 'Members list', 'manage_options', 'my-menu2', 'memberslist' );
}

/* admin main menu */
function my_menu_output(){
echo "<h2>Send Bulk Email</h2>";

echo '<form method="post">';
echo '<input style="border:1px solid; type=text" placeholder="Subject" width="358" name="subject"><br><br>';
echo '<textarea style="border:1px solid;" name="message" rows="5" cols="40" placeholder="Message"></textarea> <br><br>';
echo '<input style="border:1px solid;" type="submit" name="submit" value="Send Bulk Email" class="bulk_email">';

echo '</form>';

if(isset($_POST['submit'])){

$subjectmail = $_POST['subject'];
$messagemail = $_POST['message'];

global $wpdb;
$retrieve_data = $wpdb->get_results( "SELECT nonmember_email FROM wp_non_member" );

$emails = array();
foreach($retrieve_data as $retrieve_datas){
$emails[] = $retrieve_datas->nonmember_email;
}
$send_email = implode(",",$emails);

$blogusers = get_users( 'role=administrator' );
$user_email=array();
foreach ( $blogusers as $user ) {
$user_email[]=$user->user_email;
}
$from_email=implode(",",$user_email);

$multiple_recipients = array($send_email,$from_email);
$subject = $subjectmail;
$message = $messagemail;
wp_mail( $multiple_recipients, $subject, $message );
?><script>
window.location = document.URL;
</script><?php
}
}

/* Admin sub menu */
function memberslist(){
echo "<h2>All Nonmembers User</h2>";
global $wpdb;

$retrieve_data = $wpdb->get_results( "SELECT * FROM wp_non_member" );
echo '<table class="table table-striped"><tr><th>Name</th><th>Email</th></tr>';
foreach ($retrieve_data as $retrieved_data){
echo '<tr><td>'. $retrieved_data->nonmember_name.'</td>';
echo '<td>'.$retrieved_data->nonmember_email.'</td></tr>';
}
echo '</table>';
}

Advertisements

Avoid form auto submit on page refreshing


<form>

......

</form>

if(isset($_POST['submit'])) {

......

?><script>
window.location = document.URL;    // 'document.url' is get current url and 'windo.location' isredirect on it.
</script><?php

}

Add admin menu and submenu page


add_action('admin_menu', 'my_menu_pages');
function my_menu_pages(){
add_menu_page('None Members', 'None Members', 'manage_options', 'none-member', 'my_menu_output' );
add_submenu_page('none-member', 'Send bulk email', 'Send bulk email', 'manage_options', 'none-member' );
add_submenu_page('none-member', 'Members list', 'Members list', 'manage_options', 'my-menu2', 'memberslist' );
}
function my_menu_output(){
echo "<h2>Send Bulk Email</h2>";
}
function memberslist(){
echo "<h2>All Non members User</h2>";
}

Refrence:

http://wordpress.stackexchange.com/questions/66498/add-menu-page-with-different-name-for-first-submenu-item

Enqueue script for admin


function photoshoot_admin_scripts() {
wp_enqueue_style('medics-bootstrap',get_template_directory_uri().'/css/bootstrap.min.css',array(),'','');
}
add_action( 'admin_enqueue_scripts', 'photoshoot_admin_scripts');

All in One htaccess

.htaccess


&lt;IfModule mod_deflate.c&gt;
# Insert filters / compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/js
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/x-httpd-php
AddOutputFilterByType DEFLATE application/x-httpd-fastphp
AddOutputFilterByType DEFLATE image/svg+xml

# Ausnahme: Grafiken
SetEnvIfNoCase REQUEST_URI \.(?:gif|jpg|jpeg|png|svg)$ no-gzip dont_vary

# Drop problematic browsers
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html

# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary
&lt;/IfModule&gt;

## EXPIRES CACHING ##
&lt;IfModule mod_expires.c&gt;
ExpiresActive On
ExpiresDefault &quot;access plus 1 week&quot;
ExpiresByType image/jpg &quot;access plus 1 year&quot;
ExpiresByType image/jpeg &quot;access plus 1 year&quot;
ExpiresByType image/gif &quot;access plus 1 year&quot;
ExpiresByType image/png &quot;access plus 1 year&quot;
ExpiresByType text/css &quot;access plus 1 month&quot;
ExpiresByType text/html &quot;access plus 1 minute&quot;
ExpiresByType text/plain &quot;access plus 1 month&quot;
ExpiresByType application/pdf &quot;access plus 1 month&quot;
ExpiresByType text/javascript &quot;access plus 1 month&quot;
ExpiresByType text/x-javascript &quot;access plus 1 month&quot;
ExpiresByType application/javascript &quot;access plus 1 months&quot;
ExpiresByType application/x-javascript &quot;access plus 1 months&quot;
ExpiresByType application/x-shockwave-flash &quot;access plus 1 month&quot;
ExpiresByType image/x-icon &quot;access plus 1 year&quot;
&lt;/IfModule&gt;
## EXPIRES CACHING ##

#Alternative caching using Apache's &quot;mod_headers&quot;, if it's installed.
#Caching of common files - ENABLED
&lt;IfModule mod_headers.c&gt;
&lt;filesMatch &quot;\\.(ico|pdf|flv|jpg|jpeg|png|gif|swf)$&quot;&gt;
Header set Cache-Control &quot;max-age=2592000, public&quot;
&lt;/filesMatch&gt;

&lt;filesMatch &quot;\\.(css)$&quot;&gt;
Header set Cache-Control &quot;max-age=2592000, public&quot;
&lt;/filesMatch&gt;

&lt;filesMatch &quot;\\.(js)$&quot;&gt;
Header set Cache-Control &quot;max-age=216000, private&quot;
&lt;/filesMatch&gt;

&lt;filesMatch &quot;\\.(xml|txt)$&quot;&gt;
Header set Cache-Control &quot;max-age=216000, public, must-revalidate&quot;
&lt;/filesMatch&gt;

&lt;filesMatch &quot;\\.(html|htm|php)$&quot;&gt;
Header set Cache-Control &quot;max-age=1, private, must-revalidate&quot;
&lt;/filesMatch&gt;
&lt;/IfModule&gt;

&lt;IfModule mod_headers.c&gt;
&lt;FilesMatch &quot;\.(js|css|xml|gz)$&quot;&gt;
Header append Vary Accept-Encoding
&lt;/FilesMatch&gt;
&lt;/IfModule&gt;

&lt;IfModule mod_gzip.c&gt;
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
&lt;/IfModule&gt;

# Set Keep Alive Header
&lt;IfModule mod_headers.c&gt;
Header set Connection keep-alive
&lt;/IfModule&gt;

&lt;FilesMatch &quot;\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)(\.gz)?$&quot;&gt;
Header set Expires &quot;Thu, 15 Apr 2022 20:00:00 GMT&quot;
Header unset ETag
FileETag None
&lt;/FilesMatch&gt;

FT booster htaccess

.htaccess

</pre>
# compress text, html, javascript, css, xml:

AddOutputFilterByType DEFLATE text/plain

AddOutputFilterByType DEFLATE text/html

AddOutputFilterByType DEFLATE text/xml

AddOutputFilterByType DEFLATE text/css

AddOutputFilterByType DEFLATE application/xml

AddOutputFilterByType DEFLATE application/xhtml+xml

AddOutputFilterByType DEFLATE application/rss+xml

AddOutputFilterByType DEFLATE application/javascript

AddOutputFilterByType DEFLATE application/x-javascript

AddType x-font/otf .otf

AddType x-font/ttf .ttf

AddType x-font/eot .eot

AddType x-font/woff .woff

AddType image/x-icon .ico

AddType image/png .png

<IfModule mod_expires.c>
# Enable expirations
ExpiresActive On
# Default directive
ExpiresDefault "access plus 1 month"
# My favicon
ExpiresByType image/x-icon "access plus 1 week"
# Images
ExpiresByType image/gif "access plus 1 week"
ExpiresByType image/png "access plus 1 week"
ExpiresByType image/jpg "access plus 1 week"
ExpiresByType image/jpeg "access plus 1 week"
# CSS
ExpiresByType text/css "access 1 month"
# Javascript
ExpiresByType application/javascript "access plus 1 year"
</IfModule>
<pre>

Submit two form by one button and redirect with jQuery Ajax

&lt;/pre&gt;
&lt;form id=&quot;ajaxform_member&quot; action=&quot;&quot; method=&quot;post&quot;&gt;
&lt;table class=&quot;signup-tbl&quot;&gt;
&lt;tr&gt;
&lt;td&gt;&lt;label for=&quot;mname&quot;&gt;Name:&lt;/label&gt;&lt;/td&gt;
&lt;td&gt;&lt;input type=&quot;text&quot; required=&quot;&quot; id=&quot;mname&quot; name=&quot;mname&quot;&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;label for=&quot;maddress&quot;&gt;Address:&lt;/label&gt;&lt;/td&gt;
&lt;td&gt;&lt;input type=&quot;text&quot; name=&quot;maddress&quot; id=&quot;maddress&quot; required&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;label for=&quot;mphone_num&quot;&gt;Phone Number:&lt;/label&gt;&lt;/td&gt;
&lt;td&gt;&lt;input type=&quot;text&quot; name=&quot;mphone_num&quot; id=&quot;mphone_num&quot; required&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;label for=&quot;memail&quot;&gt;Email:&lt;/label&gt;&lt;/td&gt;
&lt;td&gt;&lt;input type=&quot;email&quot; name=&quot;memail&quot; id=&quot;memail&quot; required&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;label for=&quot;muname&quot;&gt;User Name:&lt;/label&gt;&lt;/td&gt;
&lt;td&gt;&lt;input type=&quot;text&quot; name=&quot;muname&quot; id=&quot;muname&quot; required&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;label for=&quot;mpass&quot;&gt;Password:&lt;/label&gt;&lt;/td&gt;
&lt;td&gt;&lt;input type=&quot;password&quot; name=&quot;mpass&quot; id=&quot;mpass&quot; required&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;input  class=&quot;signup-tbl-btn&quot; id=&quot;form-ajax-submit&quot; type=&quot;submit&quot; value=&quot;Membership Register&quot;  name=&quot;mregister&quot;&gt;
&lt;p class=&quot;status&quot;&gt;&lt;/p&gt;
&lt;/form&gt;

&lt;form action=&quot;https://www.sandbox.paypal.com/cgi-bin/webscr&quot; method=&quot;post&quot;&gt;
&lt;input type=&quot;hidden&quot; name=&quot;business&quot; value=&quot;raviradadiya.ommune-facilitator@gmail.com&quot; /&gt;
&lt;input type=&quot;hidden&quot; name=&quot;cmd&quot; value=&quot;_xclick-subscriptions&quot; /&gt;
&lt;!-- Instant Payment Notification &amp; Return Page Details --&gt;
&lt;input type=&quot;hidden&quot; name=&quot;notify_url&quot; value=&quot;http://localhost/JobInterviewGuide/?s2member_paypal_notify=1&quot; /&gt;
&lt;input type=&quot;hidden&quot; name=&quot;cancel_return&quot; value=&quot;http://localhost/JobInterviewGuide/&quot; /&gt;
&lt;input type=&quot;hidden&quot; name=&quot;return&quot; value=&quot;http://localhost/JobInterviewGuide/?s2member_paypal_return=1&quot; /&gt;
&lt;input type=&quot;hidden&quot; name=&quot;rm&quot; value=&quot;2&quot; /&gt;
&lt;!-- Configures Basic Checkout Fields --&gt;
&lt;input type=&quot;hidden&quot; name=&quot;lc&quot; value=&quot;&quot; /&gt;
&lt;input type=&quot;hidden&quot; name=&quot;no_shipping&quot; value=&quot;1&quot; /&gt;
&lt;input type=&quot;hidden&quot; name=&quot;no_note&quot; value=&quot;1&quot; /&gt;
&lt;input type=&quot;hidden&quot; name=&quot;custom&quot; value=&quot;localhost&quot; /&gt;
&lt;input type=&quot;hidden&quot; name=&quot;currency_code&quot; value=&quot;USD&quot; /&gt;
&lt;input type=&quot;hidden&quot; name=&quot;page_style&quot; value=&quot;paypal&quot; /&gt;
&lt;input type=&quot;hidden&quot; name=&quot;charset&quot; value=&quot;utf-8&quot; /&gt;
&lt;input type=&quot;hidden&quot; name=&quot;item_name&quot; value=&quot;Bronze Member / description and pricing details here.&quot; /&gt;
&lt;input type=&quot;hidden&quot; name=&quot;item_number&quot; value=&quot;1&quot; /&gt;
&lt;!-- Configures s2Member's Unique Invoice ID/Code  --&gt;
&lt;input type=&quot;hidden&quot; name=&quot;invoice&quot; value=&quot;&lt;?php echo S2MEMBER_VALUE_FOR_PP_INV(); ?&gt;&quot; /&gt;
&lt;!-- Identifies/Updates An Existing User/Member (when/if applicable)  --&gt;
&lt;input type=&quot;hidden&quot; name=&quot;on0&quot; value=&quot;&lt;?php echo S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON0; ?&gt;&quot; /&gt;
&lt;input type=&quot;hidden&quot; name=&quot;os0&quot; value=&quot;&lt;?php echo S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS0; ?&gt;&quot; /&gt;
&lt;!-- Identifies The Customer's IP Address For Tracking --&gt;
&lt;input type=&quot;hidden&quot; name=&quot;on1&quot; value=&quot;&lt;?php echo S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON1; ?&gt;&quot; /&gt;
&lt;input type=&quot;hidden&quot; name=&quot;os1&quot; value=&quot;&lt;?php echo S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS1; ?&gt;&quot; /&gt;
&lt;!-- Controls Modify Behavior At PayPal Checkout --&gt;
&lt;input type=&quot;hidden&quot; name=&quot;modify&quot; value=&quot;0&quot; /&gt;
&lt;!-- Customizes Prices, Payments &amp; Billing Cycle --&gt;
&lt;!--&lt;input type=&quot;hidden&quot; name=&quot;amount&quot; value=&quot;0.01&quot; /&gt;--&gt;
&lt;input type=&quot;hidden&quot; name=&quot;src&quot; value=&quot;1&quot; /&gt;
&lt;input type=&quot;hidden&quot; name=&quot;srt&quot; value=&quot;&quot; /&gt;
&lt;input type=&quot;hidden&quot; name=&quot;sra&quot; value=&quot;1&quot; /&gt;
&lt;!--&lt;input type=&quot;hidden&quot; name=&quot;a1&quot; value=&quot;0&quot; /&gt;--&gt;
&lt;!--&lt;input type=&quot;hidden&quot; name=&quot;p1&quot; value=&quot;0&quot; /&gt;--&gt;
&lt;!--&lt;input type=&quot;hidden&quot; name=&quot;t1&quot; value=&quot;D&quot; /&gt;--&gt;
&lt;input type=&quot;hidden&quot; name=&quot;a3&quot; value=&quot;0.01&quot; /&gt;
&lt;input type=&quot;hidden&quot; name=&quot;p3&quot; value=&quot;1&quot; /&gt;
&lt;input type=&quot;hidden&quot; name=&quot;t3&quot; value=&quot;M&quot; /&gt;
&lt;!-- Displays The PayPal Image Button --&gt;
&lt;input class=&quot;paypal&quot;  type=&quot;submit&quot; src=&quot;https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif&quot; style=&quot;width:auto; height:auto; border:0;&quot; alt=&quot;PayPal&quot; /&gt;
&lt;/form&gt;
&lt;pre&gt;

ajax.signup.js

&lt;/pre&gt;
jQuery(document).ready(function($) {
// Perform AJAX send mail and create user on form submit
$('form#ajaxform_member').on('submit', function(e){
$('form#ajaxform_member p.status').show().text(ajax_signup_object.loadingmessage);
$.ajax({
type: 'POST',
dataType: 'json',
url: ajax_signup_object.ajaxurl,
data: {
'action': 'member', //calls wp_ajax_nopriv_ajaxsignup
'mname': $('form#ajaxform_member #mname').val(),
'maddress': $('form#ajaxform_member #maddress').val(),
'mphone_num': $('form#ajaxform_member #mphone_num').val(),
'memail': $('form#ajaxform_member #memail').val(),
'muname': $('form#ajaxform_member #muname').val(),
'mpass': $('form#ajaxform_member #mpass').val(),
},
success: function (response) {
//window.location.href='http://localhost/JobInterviewGuide/paypal.php';
}
});
e.preventDefault();
});
$(&quot;.paypal&quot;).click(function(){
alert(&quot;The paragraph was clicked.&quot;);
$(&quot;#form-ajax-submit&quot;).trigger(&quot;click&quot;);
//$(&quot;paypal&quot;).trigger(&quot;click&quot;);
});
});
&lt;pre&gt;
%d bloggers like this: