About replying custom field security
-
I want to check if the custom field at reply is “AllowedURL”.
If applicable to “AllowURL”, I would like to have the custom field value go into the database, but can you tell me the correct way to write the following code?
add_action( 'bbp_new_reply', 'bbp_save_reply_extra_fields', 10, 1 ); add_action( 'bbp_edit_reply', 'bbp_save_reply_extra_fields', 10, 1 ); function bbp_save_reply_extra_fields( $reply_id ) { $input_url = $_POST['input_url']; $AllowURL = [ '^http?://example.com/[^/]{10}$', '^http?://example.net/[^/]{20}$' ]; foreach ( $AllowURL as $AU ){ if( @preg_match( '|'.$AU.'|', $input_url ) ) { if ( isset($_POST) && $_POST['input_url']!='' ) { update_post_meta( $reply_id, 'input_url', $_POST['input_url'] ); } } } }
I look forward to your response.
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- You must be logged in to reply to this topic.