• Resolved Ike Ten

    (@ike-ten)


    Thanks for your awesome plugin.
    My issue is quite unique and kindly assist if possible
    I successfully set up the plugin settings and deactivated woocommerce,bbpress and buddypress on my home page. I realized that the homepage returns error “The page isn’t working. Site is currently unable to handle this request. HTTP ERROR 500′

    My site is membership site with the following plugins
    Wordpress: 4.5.2
    Buddypress: 2.5.2
    Bbpress : 2.5.8
    Woocomerce: 2.5.5
    Groups by itthinx: 1.10.2 // as the restriction plugin
    theme : twenty sixteen

    This is all the trouble shooting I did.
    I reset the page back to defaults — Pages Loads fine
    Tried putting other plugins except woocoomerce, buddypress and bbpress –pages loads fine
    I tried switching off the three plugins on different pages —Same error.
    Tried deactivating all plugins one by one and also keeping just one plugin active with plugin organizer –same loading error.
    Change themes back to twenty sixteen and fifteen—same error.
    Reinstalled wordpress– same error.
    Unchecked all options in plugin organizer except Selective Plugin Loading.–same error
    Set up wordpress on a new dev sit and even on local install — same error persists.

    Then I deleted all functions in my functions.php and wow– plugin organizer now works with buddypress, bbpress and woocomece off. I went down to isolate the specific functions that casued the conflict and error with plugin organizer. They were functions related to woocomerce, buddpress and wordpress.
    In summary all my functions to restrict buddypress to members and woocommerce functions eg translate and gettext functions when active in functions.php causes the error.

    I have currently deactivated plugin organizer and now using dequeue functions to remove scripts and plugins from pages. Below are my functions.
    Can you suggest possible ways to resolve the conflict and get plugin organizer working on my setup?

    Thanks in advance.

    // Restrict access to buddypress pages
    
    function bpfr_guest_redirect() {
    global $bp;
    
    if( bp_is_activity_component() || bp_is_groups_component() || bp_is_blogs_component() || bp_is_directory() || bp_is_user() || 
    
    bp_is_members_component() || is_bbpress() ) {
    
    	// not logged in user - user will be redirect to join page
    	if ( !is_user_logged_in() ) { 
    
    		wp_redirect( get_option('siteurl') . '/join' );
    
    			}
    		}
    
    // If the user is a paid member
    if( bp_is_activity_component() || bp_is_groups_component() || bp_is_blogs_component() || bp_is_directory() || bp_is_user() || 
    
    bp_is_members_component() || is_bbpress() ) {
    
    		if( is_user_logged_in() && current_user_can('paid_member') ) {  // groups capability paid_member
    
    		return;
    
    			}
    	}	
    
    if( bp_is_activity_component() || bp_is_groups_component() || bp_is_blogs_component() ) {
    
    		if( is_user_logged_in() && current_user_can('free_member') ) { 
    
    		wp_redirect( get_option('siteurl') . '/memberships' );
    
    			}
    	}
    }
    
    add_filter('get_header','bpfr_guest_redirect', 1 );
    
    // Woocommerce Translate words
    function theme_sort_change( $translated_text, $text, $domain ) {
    
    	if ( is_woocommerce() || is_shop() ) {
    
    	switch ( $translated_text ) {
    
    	case 'product' :
    		$translated_text = __( 'item', 'theme_text_domain' );
    		break;
    
    	}
    }
    
    return $translated_text;
    
    }
    
    // Translate 'Product' text to Name on Cart and Checkout Page
    // ==========================================================================
    
    add_filter( 'gettext', 'crowdinfund_text_strings', 20, 3 );
    
    function crowdinfund_text_strings( $translated_text, $text, $domain ) {
    
    	if( is_cart() || is_checkout() ) {
    
            switch ( $translated_text ) {
    
                case 'Product' :
    
                    $translated_text = __( 'Name', 'theme_text_domain' );
                    break;
    
            	}
            }
    
        return $translated_text;
    }

    https://wordpress.org/plugins/plugin-organizer/

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Jeff Sterup

    (@foomagoo)

    It’s because the functions you are calling don’t exist if the plug-ins are disabled.

    Thread Starter Ike Ten

    (@ike-ten)

    Thanks for explaining and is there any work around for it?
    Sorry am a bit new to wordpress funtions.

    Thread Starter Ike Ten

    (@ike-ten)

    Found a solution.

    Thanks for pointing out the problem.

    Plugin Author Jeff Sterup

    (@foomagoo)

    You could put an if statement around the whole thing and check if $bp is an object.

    if (is_object($bp)) {
    
    }

    The function you are using is only available in the admin. The is_object function is a core php function and will be available everywhere by default. If buddypress isn’t active on the page $bp will not be an object.

    Thread Starter Ike Ten

    (@ike-ten)

    Thank you, I will try that and give you feedback.

    I know this is out of the support offered here but can you kindly recommend a a simple solution as the above for woocoomerce?

    In the mean I will be learning on the is_object function and how to use it to resolve future issues.

    Thanks in advance for your and best regards to you.

    Plugin Author Jeff Sterup

    (@foomagoo)

    You could try

    if (class_exists('WooCommerce')) {
    
    }

    That plugin registers the WooCommerce class when it gets loaded.

    Thread Starter Ike Ten

    (@ike-ten)

    Thanks Jeff All my woocommerce functions now work with plugin organiser when wrapped in the code you provided above. I even tried random codes and all work
    Am on the buddypress functions now. I will update here when am done and hopefully move all to my live site. Thanks again.

    Thread Starter Ike Ten

    (@ike-ten)

    Update:
    All issues are resolved and plugin organiser is working great. I ended using this if statement

    if ( class_exists('BuddyPress') ) {
    
      //Your function or code goes here.
    
       }

    to wrap buddypress custom functions; similar to what you suggested for custom woocommerce functions.

    This is a lesson learned the hard way. Always know what you are doing and apply best standards.

    Thanks for your time and patience @foomagoo or should I just say thank you Jeff!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Conflict with Custom Functions for Buddypress, bbbpress and Woocomerce’ is closed to new replies.