• Resolved prabowo

    (@prabowo)


    Hi Ahn,

    I want to ask something about meta box, is it possible to add some custom functions before process submitting, for example like this…

    1. I create an input text box on the post
    2. When I create a new post, I fill that text box with some value, for example, google.com
    3. But then before the value saved I add base64 encoding
    4. So when I display that value, the result would be Z29vZ2xlLmNvbQ==

    I don’t want to encode the value when its display, for example, echo base64_encode(rwmb_meta( ‘input_id’ )); I want the encoding process happens when publish button pushed

    Is it possible?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Anh Tran

    (@rilwis)

    Hello,

    Yes, it’s possible. Meta Box has an action rwmb_before_save_post that fires before the saving process. You can use it to do whatever you want. Read more about this action.

    If all you need is just changing the value of a field before saving into the database, you probably can filter the value.

    Wow I didn’t know if the plugin have this function

    Can u give me sample how to use it? Sorry still new using this plugin and really interest to explore more

    Thx for this beautiful plugin @rilwis

    If you just need to change the field value, use this code:

    add_filter( 'rwmb_FIELDID_value', function( $new, $field, $old ) {
        return base46_encode( $new );
    } );
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Add functions before submit’ is closed to new replies.