好的,我有下面的php,它运行正常,直到IF,但无论我做什么,我都无法让bp\\U核心消息在屏幕上激发,它只会给我保存的更改消息。。。为什么我做错了什么!
function valid_postcode ($self) {
$getFieldID = $self->field_id;
$PostCodeFieldID = 23;
$postcodecheck = $_POST[\'field_23\'];
if ( $getFieldID == $PostCodeFieldID || $postcodecheck == \'\'){
$GetValuePost = $self->value;
$regex = \'/[a-z][0-9][a-z][- ]?[0-9][a-z][0-9]$/i\';
if(!preg_match($regex, $GetValuePost)) {
bp_core_add_message( __( \'That Postcode is invalid. Check the formatting and try again.\', \'buddypress\' ), \'error\' );
}elseif (!isset($getFieldID)) {
bp_core_add_message( __( \'You need to fill out the post code.\', \'buddypress\' ), \'error\' );
}
}
}
add_action( \'xprofile_data_before_save\', \'valid_postcode\', 1, 1 );