Search Guides
Exact matches only
Search in title
Search in content
Search in posts
Search in pages
Filter by Categories
Blog
Business
Creative
Design
Ecommerce
Email Marketing
Facebook
Google
Google Analytics
Inspiration
Landing Page
Mailchimp
Portfolio
SEO
Social Media
Tips & Tricks
Tutorials
Twitter
Water Cooler
Webmaster Tools
Website
Wordpress
WordPress Tutorials
{ "homeurl": "http://simpleturtle.com/", "resultstype": "vertical", "resultsposition": "hover", "itemscount": 5, "imagewidth": 70, "imageheight": 70, "resultitemheight": "70px", "showauthor": 0, "showdate": 0, "showdescription": 0, "charcount": 3, "noresultstext": "No results!", "didyoumeantext": "Did you mean:", "defaultImage": "http://simpleturtle.com/wp-content/plugins/ajax-search-lite/img/default.jpg", "highlight": 0, "highlightwholewords": 0, "scrollToResults": 0, "resultareaclickable": 1, "defaultsearchtext": "", "autocomplete": { "enabled" : 1, "lang" : "en" }, "triggerontype": 1, "triggeronclick": 1, "redirectonclick": 0, "trigger_on_facet_change": 0, "settingsimagepos": "right", "hresultanimation": "fx-none", "vresultanimation": "fx-none", "hresulthidedesc": "1", "prescontainerheight": "400px", "pshowsubtitle": "0", "pshowdesc": "1", "closeOnDocClick": 1, "iifNoImage": "description", "iiRows": 2, "iitemsWidth": 200, "iitemsHeight": 200, "iishowOverlay": 1, "iiblurOverlay": 1, "iihideContent": 1, "iianimation": "1", "analytics": 0, "analyticsString": "ajax_search-{asl_term}", "redirectonclick": 0, "redirectClickTo": "results_page", "redirect_on_enter": 0, "redirectEnterTo": "results_page", "overridewpdefault": "0" }

Email Verification code for Woocommerce

There isn’t a plugin about that really allows you to verify email addresses so you stop getting spam/fake emails when users signup or buy from your Woocommerce store, but thanks to Hungred – there is now a simple bit of code you can add to your WordPress website.

 

So basically, all you need to do is add this code below to your activate themes functions.php file.

 

// this is just to prevent the user log in automatically after register
function wc_registration_redirect( $redirect_to ) {
        wp_logout();
        wp_redirect( '/sign-in/?q=');
        exit;
}
// when user login, we will check whether this guy email is verify
function wp_authenticate_user( $userdata ) {
        $isActivated = get_user_meta($userdata->ID, 'is_activated', true);
        if ( !$isActivated ) {
                $userdata = new WP_Error(
                                'inkfool_confirmation_error',
                                __( 'ERROR: Your account has to be activated before you can login. You can resend by clicking .$userdata->ID.'">here', 'inkfool' )
                                );
        }
        return $userdata;
}
// when a user register we need to send them an email to verify their account
function my_user_register($user_id) {
        // get user data
        $user_info = get_userdata($user_id);
        // create md5 code to verify later
        $code = md5(time());
        // make it into a code to send it to user via email
        $string = array('id'=>$user_id, 'code'=>$code);
        // create the activation code and activation status
        update_user_meta($user_id, 'is_activated', 0);
        update_user_meta($user_id, 'activationcode', $code);
        // create the url
        $url = get_site_url(). '/sign-in/?p=' .base64_encode( serialize($string));
        // basically we will edit here to make this nicer
        $html = 'Please click the following links .$url.'">'.$url.'';
        // send an email out to user
        wc_mail($user_info->user_email, __('Please activate your account'), $html);
}
// we need this to handle all the getty hacks i made
function my_init(){
        // check whether we get the activation message
        if(isset($_GET['p'])){
                $data = unserialize(base64_decode($_GET['p']));
                $code = get_user_meta($data['id'], 'activationcode', true);
                // check whether the code given is the same as ours
                if($code == $data['code']){
                        // update the db on the activation process
                        update_user_meta($data['id'], 'is_activated', 1);
                        wc_add_notice( __( 'Success: Your account has been activated! ', 'inkfool' )  );
                }else{
                        wc_add_notice( __( 'Error: Activation fails, please contact our administrator. ', 'inkfool' )  );
                }
        }
        if(isset($_GET['q'])){
                wc_add_notice( __( 'Error: Your account has to be activated before you can login. Please check your email.', 'inkfool' ) );
        }
        if(isset($_GET['u'])){
                my_user_register($_GET['u']);
                wc_add_notice( __( 'Succes: Your activation email has been resend. Please check your email.', 'inkfool' ) );
        }
}
// hooks handler
add_action( 'init', 'my_init' );
add_filter('woocommerce_registration_redirect', 'wc_registration_redirect');
add_filter('wp_authenticate_user', 'wp_authenticate_user',10,2);
add_action('user_register', 'my_user_register',10,2);

 

1 1

Signup and refer 3 friends and we will give you 60% off everything!

Exact matches only
Search in title
Search in content
Search in posts
Search in pages
Filter by Categories
Blog
Business
Creative
Design
Ecommerce
Email Marketing
Facebook
Google
Google Analytics
Inspiration
Landing Page
Mailchimp
Portfolio
SEO
Social Media
Tips & Tricks
Tutorials
Twitter
Water Cooler
Webmaster Tools
Website
Wordpress
WordPress Tutorials
{ "homeurl": "http://simpleturtle.com/", "resultstype": "vertical", "resultsposition": "hover", "itemscount": 5, "imagewidth": 70, "imageheight": 70, "resultitemheight": "70px", "showauthor": 0, "showdate": 0, "showdescription": 0, "charcount": 3, "noresultstext": "No results!", "didyoumeantext": "Did you mean:", "defaultImage": "http://simpleturtle.com/wp-content/plugins/ajax-search-lite/img/default.jpg", "highlight": 0, "highlightwholewords": 0, "scrollToResults": 0, "resultareaclickable": 1, "defaultsearchtext": "", "autocomplete": { "enabled" : 1, "lang" : "en" }, "triggerontype": 1, "triggeronclick": 1, "redirectonclick": 0, "trigger_on_facet_change": 0, "settingsimagepos": "right", "hresultanimation": "fx-none", "vresultanimation": "fx-none", "hresulthidedesc": "1", "prescontainerheight": "400px", "pshowsubtitle": "0", "pshowdesc": "1", "closeOnDocClick": 1, "iifNoImage": "description", "iiRows": 2, "iitemsWidth": 200, "iitemsHeight": 200, "iishowOverlay": 1, "iiblurOverlay": 1, "iihideContent": 1, "iianimation": "1", "analytics": 0, "analyticsString": "ajax_search-{asl_term}", "redirectonclick": 0, "redirectClickTo": "results_page", "redirect_on_enter": 0, "redirectEnterTo": "results_page", "overridewpdefault": "0" }