• Resolved develobaby

    (@bornefysioterapi)


    Hey there,

    I’m trying to integrate Woocommerce Memberships with MSLS. The immediate problem is that membership plans are a custom post type with a custom back end editor, ie. I cannot associate translated membership plans with one another using the usual UI elements. I there a simple php snippet, I can “run once” to create associations between existing posts (i.e. memberships plans)?

    Thanks, Maria

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Dennis Ploetner

    (@realloc)

    I wrote something in the past that can illustrate a bit what you want to achieve: Msls Importer

    It is quite outdated code but it wanted to backup the MSLS options in a JSON file and provides also functionality to import those files back.

    Thread Starter develobaby

    (@bornefysioterapi)

    Uuh – nice! Thank you, Dennis!

    Here’s a crude example (without any error handling) for anybody in a similar situation:

    add_action( 'wp_loaded', function() {
    $post_tx = array(
    'en_US' => 111, // adjust this array to your locales and post ids
    'da_DK' => 222, // (do this right or your will regret it!)
    'de_DE' => 333,
    );
    foreach(msls_blog_collection()->get_objects() as $blog) {
    $locale = $blog->get_language();
    $switch = $blog->userblog_id != get_current_blog_id();
    if ($switch) switch_to_blog($blog->userblog_id);
    $key = 'msls_' . $post_tx[$locale];
    $value = $post_tx;
    unset($value[$locale]);
    add_option($key, $value, '', false);
    if ($switch) restore_current_blog();
    }
    });

    Best, Maria

    Plugin Author Dennis Ploetner

    (@realloc)

    Great! We can maybe give the importer some of the love it deserves. I will see what I can do there.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Manually create association’ is closed to new replies.