i have the following Problem and i have no ideas left. I try to explain: We have some Producttests you need to register for. A Post can be a Producttest, wich is indicated by a checkbox in the editscreen. So if the checkbox is checked there will be a formular attached to the post via the_content filter. Works fine till then. After register an opt-in email is being send to the user for activating himself. And here is the Problem: for the activation url i attached the users email, a generated key and a action variable. I just generate the string and put it in the email. The logic for activation is in the_content filter either. It looks like this:
public function post_show_form( $content ) {
if( !is_single() ) return $content;
$file = 'form';
if( !( $val = get_post_meta( get_the_id(), 'is_producttest', TRUE ) ) ) return $content;
if( isset( $_GET[ 'optin_produkttest' ] ) && !empty($_GET[ 'optin_produkttest' ]) ) {
if( $this->model->already_registered( $_GET[ 'email' ] ) ) {
if( $this->model->activate( $_GET[ 'email' ], $_GET[ 'regkey' ] ) ) {
if( function_exists( 'activate_user_in_cr' ) ) {
activate_user_in_cr( $_GET[ 'email' ] );
}
return '<h1>Success</h1>' . $content;
}
} else {
return $content . '<h1>Error</h1>';
}
} else {
$start_date = new \DateTime(get_field( 'form_test_startdate', FALSE, FALSE ));
$end_date = new \DateTime(get_field( 'form_test_enddate', FALSE, FALSE ));
$now_date = new \DateTime(date( "Ymd"));
if( $now_date < $start_date){
$file = 'form';
}else{
if( $now_date < $end_date ){
$file = 'running';
} else{
$file = 'expired';
}
}
return $content . $this->view->get_template( $file );
}
}
The problem: the user is always activated immediatly and the "isset( $_GET[ 'optin_produkttest' ] ) && !empty($_GET[ 'optin_produkttest' ])" is always set and they have the right values but i dont set them, EVER. How come they are set anyway. How is that possible, i dont understand it at all.
I hope you understand what i mean, if not ask please. I need to fix this.
Thanks