Home Forums Bug Reports get_field does not return values,in WPMU with 'switch_to_blog'


get_field does not return values,in WPMU with 'switch_to_blog'

  • Under MPMU environment, switching to other blogs by using ‘switch_to_blog()’.
    I use ‘get_field’ to obtain the value of the repeater field other blogs, it has not been possible to obtain the value.

    In the blog, which has a value of repeater field,(blog_id=1)
    var_dump(get_field('repeater_field', '999'));
    -> Return the correct value.

    In the blog do not have the value of the repeater field,(blog_id=2)

    var_dump(get_field('repeater_field', '999'));

    ->Return incorrect values.
    string(1) "1"

    I’m sure that ‘get_field’ with ‘switch_to_blog()’ works correctly except in repeaer field.

    Please tell me how to avoid error. Or you ask the immediate correction.

  • Hi @[email protected]

    If I recall, doesn’t WPMU create new tables for each site in the db. Switching the blog should switch the tables being used. Is the repeater in all the tables?

  • Thank you for answering.
    I’m sorry, the your question does not understand.
    The “new table”, “all the tables”, what do you refer to?

  • Hi Maruya,

    In your example you’re not switching to blog id 2 tho? Is this just an error in your example or have you overlooked this? 🙂

  • Hi Jonathan.

    I was able to determine the conditions under which this phenomenon occurs.
    When I get the value of a custom field of Site2 that are not defined in Site1,
    I text field can be acquired. However repeater field could not be obtained.

    In my environment, I just added the definition of the same custom field and Site2 to Site1, were able to correctly get the value of the repeater field.
    I definition of custom fields, was read by the plug-in model.

    However, it was subjected to the same test in the other WP environment, even if there is no definition of the custom field in Site1, were able to correctly get the value of the repeater field.

    I do not know of two environment differences.
    Do you have something you the idea?

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

You must be logged in to reply to this topic.