Title: Remove action inside Class constructor
Last modified: November 28, 2022

---

# Remove action inside Class constructor

 *  Resolved [Isabel Pinhel](https://wordpress.org/support/users/isabelpinhel/)
 * (@isabelpinhel)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/remove-action-inside-class-constructor/)
 * Hi there,
 * I need to remove an action added inside a Class constructor without resorting
   to editing plugin files but have had no luck so far.
    The action I am trying 
   to remove is located on line 23 of wc-vendors/classes/admin/class-admin-users.
   php and is the following: `add_action( 'edit_user_profile', array( $this, 'show_extra_profile_fields'));`
 * Here is what I have tried so far to no avail in my theme’s functions.php file:
 *     ```
       add_action( 'wp_head', 'remove_wc_vendors_actions' );
       function remove_wc_vendors_actions() {
           if ( is_callable( array( $WCV_Admin_Users, 'show_extra_profile_fields' ) ) ) {
       		global $WCV_Admin_Users;
       		remove_action( 'edit_user_profile' , array( $WCV_Admin_Users, 'show_extra_profile_fields' ) );
           }
       }
       ```
   
 *     ```
       add_action( 'wp_head', 'remove_wc_vendors_actions' );
       function remove_wc_vendors_actions() {
           if ( is_callable( array( 'WCV_Admin_Users', 'show_extra_profile_fields' ) ) ) {
       		remove_action( 'edit_user_profile' , array( 'WCV_Admin_Users', 'show_extra_profile_fields' ) );
       	}
       }
       ```
   
 *     ```
       add_action( 'wp_head', 'remove_wc_vendors_actions' );
       function remove_wc_vendors_actions() {
           if ( is_callable( 'WCV_Admin_Users::show_extra_profile_fields' ) ) {
       		remove_action( 'edit_user_profile', 'WCV_Admin_Users::show_extra_profile_fields' );
       	}
   
       }
       ```
   
 * Please could you provide code to remove this action?
    Many thanks, Isabel
    -  This topic was modified 3 years, 6 months ago by [Isabel Pinhel](https://wordpress.org/support/users/isabelpinhel/).

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [noquest](https://wordpress.org/support/users/noquest/)
 * (@noquest)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/remove-action-inside-class-constructor/#post-16243257)
 * Hi [@isabelpinhel](https://wordpress.org/support/users/isabelpinhel/),
 * I’ll check this with the team. I’ll update you if this is possible.
 * Cheers,
    Lloyd
 *  Thread Starter [Isabel Pinhel](https://wordpress.org/support/users/isabelpinhel/)
 * (@isabelpinhel)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/remove-action-inside-class-constructor/#post-16243726)
 * Hi,
 * Thanks so much! Look forward to a positive outcome.
 * Isabel
 *  [noquest](https://wordpress.org/support/users/noquest/)
 * (@noquest)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/remove-action-inside-class-constructor/#post-16246635)
 * Hi [@isabelpinhel](https://wordpress.org/support/users/isabelpinhel/),
 * Can you try the following:
 *     ```
       add_action( 'admin_init', 'remove_extra_profile_fields', 1 );
   
       /**
        * Remove user extra profile fields.
        */
       function remove_extra_profile_fields() {
       	global $wp_filter;
       	if ( ! isset( $wp_filter['edit_user_profile'][10] ) || ! is_array( $wp_filter['edit_user_profile'][10] ) ) {
       		return false;
       	}
   
       	foreach ( $wp_filter['edit_user_profile'][10] as $unique_id => $value ) {
       		if ( is_object( $value['function'][0] ) && $value['function'][1] === 'show_extra_profile_fields' && get_class( $value['function'][0] ) ) {
       			if ( is_a( $wp_filter['edit_user_profile'], 'WP_Hook' ) ) {
       				unset( $wp_filter['edit_user_profile']->callbacks[10][ $unique_id ] );
       			} else {
       				unset( $wp_filter['edit_user_profile'][10][ $unique_id ] );
       			}
       		}
       	}
       	return false;
       }
       ```
   
 * Cheers,
    Lloyd
 *  Thread Starter [Isabel Pinhel](https://wordpress.org/support/users/isabelpinhel/)
 * (@isabelpinhel)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/remove-action-inside-class-constructor/#post-16257449)
 * Hi Lloyd,
 * The code worked!
    Many thanks! Isabel

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Remove action inside Class constructor’ is closed to new replies.

 * ![](https://ps.w.org/wc-vendors/assets/icon.svg?rev=1645455)
 * [WC Vendors - WooCommerce Multivendor, WooCommerce Marketplace, Product Vendors](https://wordpress.org/plugins/wc-vendors/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wc-vendors/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wc-vendors/)
 * [Active Topics](https://wordpress.org/support/plugin/wc-vendors/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wc-vendors/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wc-vendors/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [Isabel Pinhel](https://wordpress.org/support/users/isabelpinhel/)
 * Last activity: [3 years, 5 months ago](https://wordpress.org/support/topic/remove-action-inside-class-constructor/#post-16257449)
 * Status: resolved