Tips and Tricks HQ Support

Support site for Tips and Tricks HQ premium products

  • Home
  • Contact Us
  • Documentation
  • Forum Home
    • Forum
    • Forum Search
    • Forum Login
    • Forum Registration

WP eMember and WPML integration proposal.

by

Tips and Tricks HQ Support Portal › Forums › WP eMember › WP eMember Tweaks › WP eMember and WPML integration proposal.

Tagged: wp membership, wpml

  • This topic has 1 reply, 2 voices, and was last updated 11 years, 5 months ago by admin.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • December 3, 2013 at 10:54 am #10159
    ict@lago.it
    Member

    Hello, our environment is:

    – WordPress 3.5.1

    – WPML 2.6.3

    – WP eMembers 8.7.6

    We found a problem with the post translation: each language different then the the default one (setted on the WPML dashboard), cause a “Your membership level does not allow you to view the rest of the content.”

    This problem is due to a missing integration between the plugins.

    In the dashboard, probably due to the WPML, are showed only the posts in default language but, when in function auth_check_post (emember_access_checkers.php file) you check the grants, you use the current id of the post (that is different for each translation).

    I resolve this problem modify the function like this

    function auth_check_post($content){
    global $post;
    $id = $post->ID;
    if(empty($id)) return $content;

    //lago.it start
    $id = apply_filters( 'lago_get_wpml_parent_id', $id );
    //lago.it end

    return check_post_content($id, $content);
    }

    and adding, on the function.php of the theme,

    add_filter( 'lago_get_wpml_parent_id', 'lago_get_wpml_parent_id' );
    function lago_get_wpml_parent_id( $id ) {
    if ( function_exists( 'icl_object_id' ) == true ) {
    return icl_object_id( $id, 'post', false, 'it' );
    }

    return $id;
    }

    The WPML api icl_object_id returns the parent id of the given post (i.e. the post in default language, where the eMember grants are setted). This code working also with the category grant because for the same effect, in the dashboard are showed the category in default language.

    Tell me if you can accept this portion of code to implement a simple integration with the one of the best WordPress translation plugin

    P.S. Given that you request, the link is [http://business.lago.it/app-lago-i-cataloghi-prendono-vita/] but, this is a production system and I already made the modification

    Than you

    December 3, 2013 at 11:17 pm #59426
    admin
    Keymaster

    I will add a filter in our auth_check_post function for the next version. So that function will look like the following:

    function auth_check_post($content){
    global $post;
    $id = $post->ID;
    if(empty($id)) return $content;
    $id = apply_filters( 'emember_auth_check_post_id', $id);
    return check_post_content($id, $content);
    }

    You can then add the following code in your functions.php or a custom plugin:

    add_filter( 'emember_auth_check_post_id', 'custom_get_wpml_parent_id' );
    function custom_get_wpml_parent_id( $id ) {
    if ( function_exists( 'icl_object_id' ) == true ) {
    return icl_object_id( $id, 'post', false, 'it' );
    }
    return $id;
    }

  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Log In

Forum Related

  • Forum Home
  • Forum Search
  • Forum Registration
  • Forum Login

Support Related Forms

  • Contact Us
  • Customer Support
  • Request a Plugin Update
  • Request Fresh Download Links

Useful Links

  • Plugin Upgrade Instructions
  • WP eStore Documentation
  • WP eMember Documentation
  • WP Affiliate Platform Documentation
  • Tips and Tricks HQ Home Page
  • Our Projects

Quick Setup Video Tutorials

  • WP eStore Video Tutorial
  • WP eMember Video Tutorial
  • WP Affiliate Platform Video Tutorial
  • Lightbox Ultimate Video Tutorial

Our Other Plugins

  • WP Express Checkout
  • Stripe Payments Plugin
  • Simple Shopping Cart Plugin
  • Simple Download Monitor

Copyright © 2025 | Tips and Tricks HQ