palsushobhan

Hide home menu for vendors and redirect to settings page

May 17th, 2023
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.86 KB | None | 0 0
  1. add_filter( 'wcfm_login_redirect', function( $redirect_to, $user ) {
  2.     if(wcfm_is_vendor()) {
  3.         $redirect_to = get_wcfm_settings_url();
  4.     }
  5.     return $redirect_to;
  6. }, 50, 2 );
  7.  
  8. add_action( 'template_redirect', function() {
  9.     global $wp, $WCFM_Query;
  10.        
  11.     if ( wcfm_is_vendor() && is_wcfm_page() ) {
  12.         $wcfm_endpoints = $WCFM_Query->get_query_vars();
  13.         $is_endpoint = false;
  14.         foreach ( $wcfm_endpoints as $key => $value ) {
  15.             if ( isset( $wp->query_vars[$key] ) ) {
  16.                 $is_endpoint = true;
  17.             }
  18.         }
  19.         if ( ! $is_endpoint ) {
  20.             wp_safe_redirect( get_wcfm_settings_url() );
  21.             exit();
  22.         }
  23.     }
  24. }, 501 );
  25.  
  26. add_filter('wcfm_is_allow_home_in_menu', function($is_allowed) {
  27.     if(wcfm_is_vendor()) {
  28.         return false;
  29.     }
  30.     return $is_allowed;
  31. });
Add Comment
Please, Sign In to add comment