• Resolved edyzen

    (@edyzen)


    Hello

    I use WordPress Multisite with subdirectories. After signup , I create subsite1 , subsite2, subsite3

    Looks like these :

    mainsite.com

    mainsite.com/subsite1

    mainsite.com/subsite2

    mainsite.com/subsite3

    Before publish post in subsite1 there are option in the sidebar to tick in the small box :

    Broadcast to

    [ ] subsite2

    [] subsite3

    My question is how to display option tick in the small box for mainsite.com

    So I want any users of subsites have option to broadcast it’s post to mainsite.com

    I hope like these below :

    Broadcast to

    [] mainsite.com or title of mainsite.com

    [] subsite2

    [] subsite3

    Thanks sir

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author edward_plainview

    (@edward_plainview)

    It sounds like the user does not have access to the main site?

    In that case, you can either add the user to the member list of the main site, or use a code snippet to add blog access or use the All Blogs add-on.

    Thread Starter edyzen

    (@edyzen)

    First for add the user to the member list of the main site is success. Thanks .

    But for another user for code snippet to add blog access still no result, I put this code in the bottom of functions.php in running theme.

    Plugin Author edward_plainview

    (@edward_plainview)

    What is the ID of the user, and what is the snippet you used?

    Thread Starter edyzen

    (@edyzen)

    function my_threewp_broadcast_get_user_writable_blogs( $action )
    {
    	$users_and_blogs = [
    		// User ID			// Blog IDs
    		38				=> [ 1 ]
    		//6				=> [ 88, 89, 91 ],
    	];
    	if ( ! isset( $users_and_blogs[ $action->user_id ] ) )
    		return;
    	
    	foreach( $users_and_blogs[ $action->user_id ] as $blog_id )
    		$action->add_access( $blog_id );
    }
    // Broadcast fills the blog list at prio 100, so use a higher number.
    add_action( 'threewp_broadcast_get_user_writable_blogs', 'my_threewp_broadcast_get_user_writable_blogs', 200 );
    

    User ID 38 got from phpmyadmin inside table wp_users.

    Plugin Author edward_plainview

    (@edward_plainview)

    That looks right to me. I am unable to say what is wrong.

    Does adding the user to the user list of site 1 not work?

    Thread Starter edyzen

    (@edyzen)

    I can add the user to the user list of mainsite.com ( ID 1).

    But this is consume many time if there are thousands users. I must add the users one by one.

    How to write code snippet for thousands of User ID to access blog ID 1 ?

    Can i write like below ?

    function my_threewp_broadcast_get_user_writable_blogs( $action )
    {
    	$users_and_blogs = [
    		// User ID			// Blog IDs
    		>=2				=> [ 1 ]
    		//6				=> [ 88, 89, 91 ],
    	];
    	if ( ! isset( $users_and_blogs[ $action->user_id ] ) )
    		return;
    	
    	foreach( $users_and_blogs[ $action->user_id ] as $blog_id )
    		$action->add_access( $blog_id );
    }
    // Broadcast fills the blog list at prio 100, so use a higher number.
    add_action( 'threewp_broadcast_get_user_writable_blogs', 'my_threewp_broadcast_get_user_writable_blogs', 200 );
    Plugin Author edward_plainview

    (@edward_plainview)

    Just replace the contents of the function with one line

    $action->add_access( 1 );

    That will add all users to site 1.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘How to broadcast post from subsite to main site?’ is closed to new replies.