0

I have a front-end plugin which allows users to modify the fields (user_meta) of their profile, and everything works except the wp_editor.

           <div class="">
                <label class="" for="dokan-store-about"><?php _e( 'About Us', 'dokan' ); ?></label>
                <div class="dokan-text-left">
                   <?php
                    $content = get_user_meta($current_user->ID, 'wpcf-store-about', true);
                    $editor_id = 'dokan-store-about';
                    wp_editor( $content, $editor_id, array('textarea_name' => 'dokan-store-about') );

                    ?>
                    <textarea name="hey"><?php echo $content?></textarea>
                </div>
            </div>

and the saving part (which works for the image field, not for the wysiwyg)

$store_image = $_POST['dokan_store_image'];
    $store_about = $_POST['dokan-store-about'];
    $store_id = get_current_user_id();
    update_user_meta( $store_id, 'wpcf-store-image', $store_image );
    update_user_meta( $store_id, 'wpcf-store-about', $store_about );

As you can see i hardcoded a textarea with the same content, and if i save it like

update_user_meta( $store_id, 'wpcf-store-about', $_POST['hey'] );

it works fine. So i don't see what is going wrong.

3
  • Have you tried logging all of the values in $_POST after the form submits to see how the data appears? It may not be getting set simply as $_POST['dokan-store-about'] like you expect.
    – Matt Keys
    Commented Nov 8, 2014 at 15:16
  • This is not the information you are asking for, BUT: There are some pretty serious security problems in your implementation here. Allowing someone to add anything they want into your database without any validation/sanitization exposes your site in a big way to being exploited. recommended reading: Validating Sanitizing and Escaping User Data
    – Matt Keys
    Commented Nov 8, 2014 at 15:19
  • Thank you Matt: about sanitizing I know..this is just a "testing" code and I will add the sanitizers later. I tried to log both POST and the meta during the savin process and it doesn't work. It always shows the old one. But if i press the button twice (submit button of the form) it does actually save it. I'm confused
    – nickelnext
    Commented Nov 8, 2014 at 18:00

1 Answer 1

1

Solved:

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

tinyMCE.triggerSave();
});

Needed to update manually the tinymce, guess because it's in an Iframe.

Thanks anyway

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.