Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Marcus (aka @msykes)

    (@netweblogic)

    You can get this to work by always setting the blog argument to 1 (or whatever your main blog ID is) using PHP and our filters.

    see the first snippet on this tutorial for a starting point:
    https://wp-events-plugin.com/tutorials/creating-custom-event-search-attributes/

    Thread Starter patricioqb

    (@patricioqb)

    Hi Marcus. Thank you for your response.

    I followed your tutorial and I understood it, but I can’t find how to do what I need from that.

    Is there a way to change the default scope or something like that? I only would need to add “OR blog_id = 1” or something like that ??

    Plugin Author Marcus (aka @msykes)

    (@netweblogic)

    in the first snippet, instead of

    $searches[‘style’] = …

    take it out of the if conditional and just make it

    $searches[‘blog’] = 1;

    Thread Starter patricioqb

    (@patricioqb)

    It is not working. If I print_r the arrays, it seems is rewriting the blog key in the array, but it is not doing anything.

    If I print the SQL query, it is still quering for the tables of the current blog and not the main blog (or both, which is what I want).

    Could you paste the exact code your using please? This will help us better see what you’re using.

    Thanks

    Thread Starter patricioqb

    (@patricioqb)

    Yes.

    Right now, I am just playing to trying to get the main blog events in all sub-blogs:

    add_filter('em_events_get_default_search','em_from_main_blog',1,2);
    add_filter('em_calendar_get_default_search','em_from_main_blog',1,2);
    function em_from_main_blog($searches){
    	$searches['blog'] = 1;
    	echo "<pre>";
    	var_dump($searches);
    	echo "</pre>";
    	return $searches;
    }

    That seems to work fine, but when I do

    var_dump($sql) on em_events_get_sql, it is still fetching for the current blog.

    Thread Starter patricioqb

    (@patricioqb)

    Update:

    I create a filter to get the events from the main blog directly from the SQL:

    add_filter('em_events_get_sql','pat_em_sql',$sql);
    function pat_em_sql($sql){
    	$orig = $sql;
    
    	$sql = "(".$orig.") UNION (".preg_replace('/wp_\d{1,2}_/','wp_',$sql).")";
    	return $sql;
    }

    The problem, of course, is permalinks not working for the “outside” events in a sub-blog.

    Plugin Author Marcus (aka @msykes)

    (@netweblogic)

    your first snippet looks ok to me

    are you using global tables mode? if not then that’d be why

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘MultiSite Network: One blog create events for all blogs’ is closed to new replies.