Home Forums Theme Support Dokan WP Editor problem on dashboard/settings

This topic is: not resolved

This topic contains 9 replies, has 3 voices, and was last updated by  Roberto 4 years, 7 months ago.

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #30018

    Roberto
    Member
    Post count: 59

    Hello

    function my_dokan_save_field(  ) {
    		$store_image = $_POST['dokan_store_image'];
    		$store_about = $_POST['dokan-store-about'];
    		$store_id = get_current_user_id();
    		// error_log(get_user_meta($store_id, 'wpcf-store-about', true));
    		// error_log($store_about);
                    update_user_meta( $store_id, 'wpcf-store-image', $store_image );
    		update_user_meta( $store_id, 'wpcf-store-about', $store_about );
    
    	}
    add_action( 'dokan_store_profile_saved', 'my_dokan_save_field' ); 

    This is the code, and

    $store_about = get_user_meta($current_user->ID, 'wpcf-store-about', true);
    $editor_id = 'dokan-store-about';
    wp_editor( $store_about, $editor_id);

    is attached with

    add_action( 'dokan_settings_after_banner', 'my_dokan_setting_field' );

    Problem is that the image is saving, while the WYSIWYG editor does not modifies the _POST[store about] unless i press the update settings button twice in a row.

    There's something wrong with the Ajax call i guess.
    I also tried to log the _POST[] and it shows the old value of the field, not what i write.

    #30049

    Sk
    Moderator
    Post count: 371

    Hello Roberto,

    Is this all you have added? I think no. please provide all your added code. I don't see any extra field in your code named dokan_store_image or dokan-store-about. May be you miss something. If not it should work properly.

    thank you.
    ๐Ÿ™‚

    #30058

    Roberto
    Member
    Post count: 59
    function my_dokan_setting_field( ) {
            global $current_user;
    		
    		//image wpcf-store-image
    		$store_image = get_user_meta( $current_user->ID, 'wpcf-store-image', true );
    		
            ?>
    
                    <div class="dokan-banner">
                        <div class="image-wrap<?php echo $store_image ? '' : ' dokan-hide'; ?>">
                            <?php $store_image_url = $store_image ? wp_get_attachment_url( $store_image ) : ''; ?>
                            <input type="hidden" class="dokan-file-field" value="<?php echo $store_image; ?>" name="dokan_store_image">
                            <img class="dokan-banner-img" src="<?php echo esc_url( $store_image_url ); ?>">
    
                            <a class="close dokan-remove-banner-image" style="">×</a>
                        </div>
    
                        <div class="button-area<?php echo $store_image ? ' dokan-hide' : ''; ?>">
                            <i class="fa fa-cloud-upload"></i>
                            <a href="#" class="dokan-banner-drag dokan-btn dokan-btn-info"><?php _e( 'Upload Cover Photo', 'my-dokan' ); ?></a>
                            <p class="help-block"><?php _e( '(Upload a Cover Photo for your store. Size has to be (1200x300) pixel. )', 'my-dokan' ); ?></p>
                        </div>
                    </div> <!-- .dokan-banner -->
    
                    <?php do_action( 'my_dokan_settings_after_store_image', $current_user); ?>
    				
    				<div class="">
                        <label class="" for="dokan-store-about"><?php _e( 'About Us', 'my-dokan' ); ?></label>
                        <div class="dokan-text-left">
                           <?php
    						$store_about = get_user_meta($current_user->ID, 'wpcf-store-about', true);
    						$editor_id = 'dokan-store-about';
    						wp_editor( $store_about, $editor_id);
    						?>
                        </div>
                    </div>
    				
    				
    				
            <?php
        }
    add_action( 'dokan_settings_after_banner', 'my_dokan_setting_field' );

    and

    //save data
    	function my_dokan_save_field(  ) {
    		$store_image = $_POST['dokan_store_image'];
    		$store_about = $_POST['dokan-store-about'];
    		$store_id = get_current_user_id();
    		// error_log(get_user_meta($store_id, 'wpcf-store-about', true));
    		// error_log($store_about);
            update_user_meta( $store_id, 'wpcf-store-image', $store_image );
    		update_user_meta( $store_id, 'wpcf-store-about', $store_about );
    
    	}
    add_action( 'dokan_store_profile_saved', 'my_dokan_save_field' ); 
    #30096

    Sk
    Moderator
    Post count: 371

    Hi,

    May be $_POST['dokan_store_image']; is getting an empty value.
    Please provide your login details by using this form -http://wedevs.com/provide-login-details/. I will have a look what is going wrong.

    Thank you ๐Ÿ™‚

    #30106

    Roberto
    Member
    Post count: 59

    Hello Mr Shaikat.
    First of all thanks for your support.

    The problem is with the WP_EDITOR, therefore with dokan-store-about.
    THe image works perfectly, and if i log using

    error_log($store_about); inside the function my_dokan_save_field what i always get is the previous value, not the current (meaning that if I have a value in the wysiwyg editor of “Value 1” and i change it with “Value 2” or anything else, when I press SUBMIT, the value logged by error_log is “value 1”.

    If I press twice in a row the submit button (double click basically) the error_log logs value and value 2, and the value 2 gets finally saved in the database (upon refresh i see value 2).

    If instead of using a wp_editor i use a plain <textarea> field named dokan-store-about everything works perfectly.

    I'll send you the username and password for the vendor user i built for you to see.

    Cheers

    #30114

    Sk
    Moderator
    Post count: 371

    The code for store-about looks ok.
    Please provide your ftp details by using this form – http://wedevs.com/provide-login-details/ . I will have a look what is going wrong.

    Thank you ๐Ÿ™‚

    #30122

    Roberto
    Member
    Post count: 59

    I will now.

    IMPORTANT: use ACTIVE FTP mode.

    #30188

    Roberto
    Member
    Post count: 59

    Any news guys?

    #30234

    sophie
    Member
    Post count: 20

    you need to update your field before update the page :

    jQuery(‘input[name=dokan_update_profile]').click(function(){

    tinyMCE.triggerSave();
    });

    dokan_update_profile = the name of your submit button

    #30322

    Roberto
    Member
    Post count: 59

    Thanks!!!!

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

The topic ‘WP Editor problem on dashboard/settings’ is closed to new replies.