Home Forums Plugin Support WP User Frontend (Free Version) Multilingual Edit Page

This topic is: not resolved

This topic contains 5 replies, has 3 voices, and was last updated by  Gonzalo 5 years, 2 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #5838

    obouilland
    Participant
    Post count: 8

    Hi.

    I am using WPML plugin to set a multilingual site, default language is english, second language is french.
    WPML manage page translation by creating a page for each language, each page has a language attribute.

    When I define the page edit in WPFUE settings, this page is used for both languages. Here is the process I have followed :
    1. Set the edit page in english admin context as ‘Edit' (my english edit page with the wpufe_edit shortcode)
    2. Switch in admin in French Language
    3. Set the edit page in french admin context as ‘Modifier' (my french edit page with the wpufe_edit shortcode)
    4. Switch in admin in English Language
    5. Problem : the settings for english are reseted, no page is selected, and wordpress will use the french edit page for both language.

    Is there a way to fix it ?

    Thank you

    #5855

    Tareq Hasan
    Keymaster
    Post count: 2831

    So what I understand, if you switch to English, the form should be in English. And when you switch to French, the form should be in French, isn't that right?

    If thats the case, WPUF isn't capable doing this yet, even with WPML.

    #5873

    obouilland
    Participant
    Post count: 8

    Ok Thank you for your reply. Do you plan to create WPML compatibility in a next future ?

    #5876

    Tareq Hasan
    Keymaster
    Post count: 2831

    Yes, that would be a cool feature ๐Ÿ™‚

    #5878

    obouilland
    Participant
    Post count: 8

    Yes, for sure !

    For those who face the same problem, i find the solution by changing your function wpuf_edit_post_link, line 217 in wpuf-functions.php like this :

    /**
     * Edit post link for frontend
     *
     * @since 0.7
     * @param string $url url of the original post edit link
     * @param int $post_id
     * @return string url of the current edit post page
     */
    function wpuf_edit_post_link( $url, $post_id ) {
        if ( is_admin() ) {
            return $url;
        }
    
        $override = wpuf_get_option( 'override_editlink', 'wpuf_general', 'yes' );
        if ( $override == 'yes' ) {
            $url = '';
            if ( wpuf_get_option( 'enable_post_edit', 'wpuf_dashboard', 'yes' ) == 'yes' ) {
                $edit_page = (int) wpuf_get_option( 'edit_page_id', 'wpuf_general' );
    			$current_language =ICL_LANGUAGE_CODE ;
    			if($current_language == 'fr') {
       			 $edit_page_wpml = icl_object_id($edit_page,'page',true);
      			}
    			else {
    				$edit_page_wpml = $edit_page ;
    				}
    			
    			
                $url = get_permalink( $edit_page_wpml );
    
                $url = wp_nonce_url( $url . '?pid=' . $post_id, 'wpuf_edit' );
            }
        }
    
        return $url;
    }
    
    add_filter( 'get_edit_post_link', 'wpuf_edit_post_link', 10, 2 );
    

    The changes are just for additional languages, no need to had anything for default language.

    Perhaps it is possible in next release just to add a function exists test on this function in order to hack it in my function.php and not have to change core plugin files.

    In the same way, here is the function I had to my function.php file in order to save a post in the correct language (same again, only needed for additional languages, not for the default one):

    
    /**
     * Update the lanuage  when the form submits
     *
     * @param type $post_id
     */
    function update_language_hook( $post_id ) {
    	$language = $_POST['icl_post_language'] = ICL_LANGUAGE_CODE;
        if ( isset( $language) && $language == 'fr' ) {
    		global $wpdb;
    		 $wpdb->update('wp_icl_translations', array('language_code'=>$language), array('element_id'=> $post_id)); 
    	}
    }
     
    add_action( 'wpuf_add_post_after_insert', 'update_language_hook');
    

    I hope it could help multilingual integration for wpufe.

    Olivier

    #14457

    Gonzalo
    Member
    Post count: 11

    Hi

    I was wondering if this has been incorporated.

    Thanks
    Gonzalo

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

The topic ‘Multilingual Edit Page’ is closed to new replies.