admin管理员组

文章数量:1130349

I have a front end built with Gatsby, connecting to WordPress via the REST API.

Each time I update a post, I need run a command to compile. Below is my attempt at automating this using the save_post filter function:

<?php

function li_rebuild_gatsby( $id, $post, $update ) {
    $command_one = "cd /home/web/public/website425";
    $command_two = "gatsby build";
    @exec( $command_one . "&& " . $command_two );
}
add_filter( 'save_post' , 'li_rebuild_gatsby' , 10, 3 );

It seems I need to change into a sudo'er and supply a password.

What is the right way to run this command?

I have a front end built with Gatsby, connecting to WordPress via the REST API.

Each time I update a post, I need run a command to compile. Below is my attempt at automating this using the save_post filter function:

<?php

function li_rebuild_gatsby( $id, $post, $update ) {
    $command_one = "cd /home/web/public/website425";
    $command_two = "gatsby build";
    @exec( $command_one . "&& " . $command_two );
}
add_filter( 'save_post' , 'li_rebuild_gatsby' , 10, 3 );

It seems I need to change into a sudo'er and supply a password.

What is the right way to run this command?

本文标签: hooksTrying to run a compile command while saving post