Last active
February 1, 2021 15:35
-
-
Save jonathanstegall/5882d38800da29f25dba2ea997b0fc26 to your computer and use it in GitHub Desktop.
process users in WordPress; delete user with a specific criteria
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| add_filter( 'object_sync_for_salesforce_pull_object_allowed', 'process_user', 10, 5 ); | |
| function process_user( $pull_allowed, $object_type, $object, $sf_sync_trigger, $salesforce_mapping ) { | |
| if ( 'Contact' === $object_type && 'deletion' === $object['LastName'] ) { | |
| $pull_allowed = false; | |
| if ( ! function_exists( 'is_plugin_active' ) ) { | |
| require_once( ABSPATH . '/wp-admin/includes/plugin.php' ); | |
| } | |
| if ( is_plugin_active( 'object-sync-for-salesforce/object-sync-for-salesforce.php' ) ) { | |
| $salesforce = Object_Sync_Salesforce::get_instance(); | |
| $mapping_object = $salesforce->mappings->get_object_maps( | |
| array( | |
| 'salesforce_id' => $object['Id'], | |
| ) | |
| ); | |
| $wordpress_id = $mapping_object['wordpress_id']; | |
| $wordpress_type = $mapping_object['wordpress_object']; | |
| $delete_user = wp_delete_user( $wordpress_id ); | |
| } | |
| } | |
| return $pull_allowed; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment