WordPress.org

Ready to get started?Download WordPress

Forums

Change contents BEFORE writing to DB (4 posts)

  1. CounterDax
    Member
    Posted 5 years ago #

    Hi all!
    I want to process the post content before it is written to the database upon saving a post. This means I cannot use filters because they only work on rendering the data (when retrieved from DB)... I must thus use an action hook. add_action('save_post', 'myFunction'); only parses the post_id and not the content. does anyone have any pointers how I should take care of this?

  2. xphilippe
    Member
    Posted 5 years ago #

    bump ...

    I want also modify the content before send it in the database

    for instance, When user write "N:\repository\ ..." I want to change it by "file://///servername/repository/ ..."

    Any idea?

    add_action('save_post','myfunction')
    function myfunction{$content=str_replace('...','...',$content);}

    thanks in advance

  3. mrmist
    Forum Janitor
    Posted 5 years ago #

    Maybe you could use WordPress shortcodes instead?

  4. s_ha_dum
    Member
    Posted 5 years ago #

    Take a look at this thread. It concerns almost the same question.

Topic Closed

This topic has been closed to new replies.

About this Topic