• Resolved nick.slatiner

    (@nickslatiner)


    Greetings,

    We are currently using Event Manager Pro for a multisite network.
    After realizing that the events added in the subsites were not appearing in the main site’s events page, I started poking around to see what was going on.

    I found out that when the WPML plugin is turned off, all the events appear as they should on the main site as well. Since WPML is a key plugin in our site, I am looking for a solution. Unfortunately the WPML Compatibility doesn’t resolve the issue.

    Any suggestions?

    Thanks,
    Nick

    https://www.ads-software.com/plugins/events-manager/

Viewing 9 replies - 1 through 9 (of 9 total)
  • Hi Nick,

    Are the missing events ones that have been translated or not?

    Thread Starter nick.slatiner

    (@nickslatiner)

    Hi,
    All the events created in the sub sites are not appearing on the main site. None was translated yet, all in the default main language.

    Plugin Support angelo_nwl

    (@angelo_nwl)

    are you using Global table modes? – https://wp-events-plugin.com/documentation/multisite/

    also, since you are using EMPro maybe you can try to use pro forums instead.

    Thread Starter nick.slatiner

    (@nickslatiner)

    Yes, I am using the Global table modes. As I mentioned, disabling the WPML plugin makes the main site’s event page show all the subsites events as it should.

    Just noting here that we’re dealing with this in the Pro forums now.

    Did you find a solution for this issue in the pro forums. I did dig a little into this and found that the sql queries that Events Manager produces don’t take into account that there are separate wp_icl_translations tables (prefix wp_, wp_2_, etc) for each blog.

    If you did find a fix, would you be kind enough to share it with non-pro users? ??

    I’m sure EM team will be able to eventually do it more elegantly, but for anybody else tackling with the same issue and urgently needs a fix, I managed to get it working by replacing a function in events-manager-wpml.php (EM’s WPML compatibility plugin).

    public static function event_searches($conditions, $args){
    	global $wpdb;
    	$current_blog_id = get_current_blog_id();
    
    	if(is_numeric($args['blog'])) {
    		$count = 1;
    		if($args['blog'] == $current_blog_id) {
    			$prefix[] = $wpdb->prefix;
    		} else {
    			switch_to_blog($args['blog']);
    			$prefix[] = $wpdb->prefix;
    			restore_current_blog();
    		}
    	} else {
    		$allblogs = $wpdb->get_col('SELECT blog_id FROM '.$wpdb->base_prefix.'blogs');
    		if($args['blog'] == '') {
    			$blogs = $allblogs;
    		} else {
    			if(is_array($args['blog'])) {
    				$array_blogs = $args['blog'];
    			} else {
    				$array_blogs = explode(',', $args['blog']);
    			}
    			foreach($array_blogs as $array_blog) {
    				if(in_array($array_blog, $allblogs)) {
    					$blogs[] = $array_blog;
    				}
    			}
    		}
    		foreach($blogs as $blog) {
    			switch_to_blog($blog);
    			$prefix[] = $wpdb->prefix;
    			restore_current_blog();
    		}
    		$count = count($blogs);
    	}
    
    	if( defined('ICL_LANGUAGE_CODE') ){
    		$conditions['wpml'] = '(';
    		for( $i = 0; $i < $count; $i++ ) {
    			$conditions['wpml'] .= EM_EVENTS_TABLE.'.post_id IN (SELECT element_id FROM '.$prefix[$i]."icl_translations WHERE language_code ='".ICL_LANGUAGE_CODE."' AND element_type='post_".EM_POST_TYPE_EVENT."')";
    			if($i < $count-1) {
    				$conditions['wpml'] .= ' OR ';
    			}
    		}
    		$conditions['wpml'] .= ')';
    	}
    	return $conditions;
    }
    Plugin Support angelo_nwl

    (@angelo_nwl)

    thanks for sharing.

    Thread Starter nick.slatiner

    (@nickslatiner)

    Thanks lsklm.
    As soon as the guys from EM Pro will find an official solution I’ll share it in here as well.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Subsite events don't appear on main site when using WPML’ is closed to new replies.