WP Editor problem on dashboard/settings

This topic contains 9 reply and 3 voices, and was last updated by Roberto 10 years ago
Viewing 9 Posts - 1 through 9 (of 9 total)
Author Posts
November 9, 2014 at 12:17 am 30018
Roberto 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.
November 9, 2014 at 4:35 pm 30049
Sk Sk

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.
🙂

November 9, 2014 at 9:14 pm 30058
Roberto Roberto
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="">&times;</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' ); 
November 10, 2014 at 12:30 pm 30096
Sk Sk

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 🙂

November 10, 2014 at 1:55 pm 30106
Roberto Roberto

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

November 10, 2014 at 3:04 pm 30114
Sk Sk

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 🙂

November 10, 2014 at 6:43 pm 30122
Roberto Roberto

I will now.

IMPORTANT: use ACTIVE FTP mode.

November 11, 2014 at 1:57 pm 30188
Roberto Roberto

Any news guys?

November 11, 2014 at 9:38 pm 30234
sophie sophie

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

November 12, 2014 at 11:18 pm 30322
Roberto Roberto

Thanks!!!!

Viewing 9 Posts - 1 through 9 (of 9 total)