Advertisement
wclovers

Remove resgistration step if use logged in

Jun 29th, 2023
904
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.01 KB | None | 0 0
  1. /** Removes registration/profile step if the user is already logged in */
  2. add_filter('wcfm_membership_registration_steps', function ($steps) {
  3.     if (is_user_logged_in()) {
  4.         if (isset($steps['registration'])) unset($steps['registration']);
  5.     }
  6.  
  7.     return $steps;
  8. });
  9.  
  10. /** Channge the current step to choose_membership if the user is already logged in */
  11. add_filter('wcfm_membership_registration_current_step', function ($step) {
  12.     if (is_user_logged_in() && $step == 'registration') {
  13.         $step = 'choose_membership';
  14.     }
  15.  
  16.     return $step;
  17. });
  18.  
  19. /** Recalculate the width of the progress step bar */
  20. add_action('wp_enqueue_scripts', function () {
  21.     ob_start();
  22.     ?>
  23.     <style>
  24.         .wcfm-membership-wrapper .wc-progress-steps li,
  25.         .woocommerce-progress-form-wrapper .wc-progress-steps li {
  26.             width: calc(100%/3);
  27.         }
  28.     </style>
  29.     <?php
  30.     $style = ob_get_clean();
  31.  
  32.     wp_add_inline_style('wcfm_membership_steps_css', $style, 'after');
  33. }, 11);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement