Advertisement
Guest User

Untitled

a guest
May 25th, 2015
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. <?php
  2. function user_autologout(){
  3. if ( is_user_logged_in() ) {
  4. $current_user = wp_get_current_user();
  5. $user_id = $current_user->ID;
  6. $approved_status = get_user_meta($user_id, 'wp-approve-user', true);
  7. //if the user hasn't been approved yet by WP Approve User plugin, destroy the cookie to kill the session and log them out
  8. if ( $approved_status == 1 ){
  9. return get_permalink(woocommerce_get_page_id('myaccount'));
  10. }
  11. else{
  12. wp_logout();
  13. return get_permalink(woocommerce_get_page_id('myaccount')) . "?approved=false";
  14. }
  15.  
  16. }
  17. }
  18.  
  19. function registration_message(){
  20. if( isset($_REQUEST['approved']) ){
  21. $approved = $_REQUEST['approved'];
  22. if ($approved == 'false') { echo '<ul class="woocommerce-info"><li><strong>Sucesso!</strong> Você será notificado quando seu acesso for liberado.</li></ul>';
  23. }
  24. }
  25. }
  26. add_action('woocommerce_before_customer_login_form', 'registration_message', 2);
  27. add_action('woocommerce_registration_redirect', 'user_autologout', 2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement