drbl91357 2019-03-21 20:59
浏览 38

动态抓取'gravity form id',它是'父页/帖子ID'

I am wondering how; in Wordpress and PHP - I could dynamically grab the current Form ID (forms come from Gravity Forms) and it's parent page/post ID. (The gravity forms are nested; with an outer page or post)

I am wanting to do this, because I'm also using a 'last modified plugin' i.e. (WP Last Modified Info) - and I need to use a Gravity Forms 'Wordpress Hook' in order for the 'Last Modified Plugin' functionality to reflect after the web forms (via gravity forms) are Saved.

I have this functionality working with the below code; however, I have many forms, and then sometimes - other users beside me, will create Forms; so I don't want to have to create this piece of code per each form that exists.


Any thoughts? In the below code; where '11' and then '921' is identified. (Via Child theme)


add_action( 'gform_after_save_form', 'lmt_update_modified_info_on_form_update', 10, 2 );

function lmt_update_modified_info_on_form_update( $form, $is_new ) {
    if ( $form['id'] == 11 ) { 
        $newdate = date( 'Y-m-d H:i:s', current_time( 'timestamp', 0 ) );
        $args = array(
            'ID'                => 921, 
            'post_modified'     => $newdate,
            'post_modified_gmt' => get_gmt_from_date( $newdate ),
        );

        wp_update_post( $args );
    }
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 请问我该如何添加自己的数据去运行蚁群算法代码
    • ¥20 用HslCommunication 连接欧姆龙 plc有时会连接失败。报异常为“未知错误”
    • ¥15 网络设备配置与管理这个该怎么弄
    • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
    • ¥20 西门子S7-Graph,S7-300,梯形图
    • ¥50 用易语言http 访问不了网页
    • ¥50 safari浏览器fetch提交数据后数据丢失问题
    • ¥15 matlab不知道怎么改,求解答!!
    • ¥15 永磁直线电机的电流环pi调不出来
    • ¥15 用stata实现聚类的代码