add_action with add_post_meta
-
Hello,
I need help for this feature.If I add post meta with a static value, it works:
add_action( "save_post", 'action_save_post_regular'); if(!function_exists('action_save_post_regular')) { // define the save_post_to_book callback function action_save_post_regular( $post_id ) { add_post_meta( $post_id, '_enable_role', 1, true ); }; }
If I need to pass a variable, I don’t know how can I do. I tied something like this, but It doesn’t work:
$variable = 'hello world'; add_action( "save_post", 'action_save_post_regular'); if(!function_exists('action_save_post_regular')) { // define the save_post_to_book callback function action_save_post_regular( $post_id, $variable ) { add_post_meta( $post_id, '_enable_role', $variable, true ); }; }
Can anyone help me?
thank you.
Bye
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘add_action with add_post_meta’ is closed to new replies.