Support

Account

Home Forums ACF PRO Network Multisite: use meta not working in multisite

Solved

Network Multisite: use meta not working in multisite

  • Hello

    I have use acf pro in multisite. I have add user in network and this user sync in three site. after i have add use meta in one site and then add same meta in other site to lost one site user meta. So can you plz help how to work use meta in multi site.

    – Thanks

  • Wordpress already work like wp_capabilities, wp_2_capabilities, wp_3_capabilities. and ACF pro not working like this way.

  • Hi @developeronetest

    Yeah the thing about users and WPMU is that while WordPress creates own tables for pretty much everything it does not create separate tables for wp_user and wp_usermeta. So when you have meta on a user it will be applied to the entire network.

    I think that this is not just an issue of wether it’s possible for ACF to add support for separate meta but also wether this is wanted. I can see use cases both where one would want separate meta AND network wide meta.

    But of course I’ll try to help you out.
    I think you might be able to achieve this by modifying the field names specifically for each site. If you register your user meta fields manually with PHP you can pass in the sites ID to get the same results as with wp_capabilities etc.

    Then when you want to fetch the user meta you’ll do the same. pass in the current sites ID in the field name.
    Here’s some example code of what I mean:

    
    if( function_exists('acf_add_local_field_group') ):
    $site_ID = get_current_blog_id();
    acf_add_local_field_group(array(
    	'key' => 'group_1',
    	'title' => 'My Group',
    	'fields' => array (
    		array (
    			'key' => 'field_1_' . $site_ID,
    			'label' => 'Sub Title',
    			'name' => 'sub_title_' . $site_ID,
    			'type' => 'text',
    		)
    	),
    	'location' => array (
    		array (
    			array (
    				'param' => 'post_type',
    				'operator' => '==',
    				'value' => 'post',
    			),
    		),
    	),
    ));
    
    endif;
    
    //And fetching anywhere in your theme
    
    $site_ID = get_current_blog_id();
    $userfield = get_field('sub_title_' . $site_ID, 'user_' . $user_ID);
    
    
  • No problem,

    Did that resolve your issue?

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.