Last active
December 20, 2024 13:41
-
-
Save yuriinalivaiko/150505bf0a34ce88a91f3a781628b78e to your computer and use it in GitHub Desktop.
Disable conflicting plugins on UM pages.
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
| <?php | |
| /** | |
| * Plugin Name: Ultimate Member - Conflicts Fix | |
| * Description: Disable conflicting plugins on UM pages. | |
| * Author: Ultimate Member support team | |
| * Author URI: https://ultimatemember.com/support/ | |
| * Version: 1.0.0 | |
| * | |
| * Add this code to the file /wp-content/mu-plugins/um_conflicts_fix.php | |
| */ | |
| if ( ! function_exists( 'um_conflicts_fix' ) ) { | |
| function um_conflicts_fix( $active_plugins ) { | |
| if ( is_admin() || wp_doing_ajax() ) { | |
| return $active_plugins; | |
| } | |
| // List of Ultimate Member pages. | |
| $pages = array( | |
| 'account', | |
| 'login', | |
| 'members', | |
| 'password-reset', | |
| 'register', | |
| 'user', | |
| ); | |
| // List of plugins that conflict with Ultimate Member. | |
| $plugins = array( | |
| 'forminator/forminator.php', | |
| 'supportcandy/supportcandy.php', | |
| ); | |
| if ( ! empty( $_SERVER['REQUEST_URI'] ) ) { | |
| $uri = trim( wp_unslash( $_SERVER['REQUEST_URI'] ), " \t\n\r\0\x0B/\\" ); | |
| if ( strpos( $uri, '?' ) ) { | |
| $uri = trim( current( explode( '?', $uri ) ) ); | |
| } | |
| if ( strpos( $uri, '/' ) ) { | |
| $uri = trim( current( explode( '/', $uri ) ) ); | |
| } | |
| if ( in_array( $uri, $pages, true ) ) { | |
| $active_plugins = array_diff( $active_plugins, $plugins ); | |
| } | |
| } | |
| return $active_plugins; | |
| } | |
| add_filter( 'option_active_plugins', 'um_conflicts_fix', 10 ); | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Most of the time when you find an issue on your site with Ultimate Member, it will be caused by a plugin or theme conflict. Follow steps in the article How to do a plugin/theme conflict test? to find plugins that conflict with Ultimate Member. Contact the plugin support to ask them solve a conflict.
As a temporary solution you can disable conflicting plugins on Ultimate Member pages. Use mu-plugin to do this.
Create the /wp-content/mu-plugins/um_conflicts_fix.php file and paste this code into the file.
Go to wp-admin > Plugins > Must-Use. You should see the "Ultimate Member - Conflicts Fix" plugin. This mu-plugin disables plugins listed in the
$pluginsarray at pages listed in the$pagesarray. You can extend these arrays if you need to disable other plugins or do it on other pages.