Support

Account

Home Forums Add-ons Options Page Change field's value before saving in db. Options page.

Solved

Change field's value before saving in db. Options page.

  • Hello,

    I’ve looked for the answer to the question in the title for last several hours testing various replies but none of them actually worked.

    What I want to achieve
    apply formatting to wysiwyg field BEFORE it is saved using this simple function:

    function escape_chbx_input() {
    	if( isset($_POST['acf']['my_wysiwyg_key']) ) {
    		custom_php_function( $_POST['acf']['my_wysiwyg_key'] );
    	}
    }

    What have I done so far
    I have found two hooks that could probably work here but apparently none of them did:

    add_filter( 'acf/save_post', 'escape_chbx_input', 5);
    and
    add_filter( 'acf/save_post', 'escape_chbx_input', 15);

    plus
    add_filter( 'acf/update_value/key=my_wysiwyg_key', 'escape_chbx_input', 15);

    Can you help me out here?
    Thank you!

  • I actually used WP’s native update_option in the hook acf/save_post.
    And that worked.

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

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.