Support

Home Forums Event Espresso Premium Change statut & notification in front

Change statut & notification in front

Posted: May 7, 2016 at 2:13 am


JacquesMivi

May 7, 2016 at 2:13 am

Hello,

I’m creating a front end page for user. I want to offer them a page to change status of participants and resend email.
I have a correct array of _REG_ID[], and $status. Now I want to call your following action

protected function _set_registration_status_from_request( $status = false, $notify = false ) {
$REG_ID = isset( $this->_req_data['_REG_ID'] ) ? (array) $this->_req_data['_REG_ID'] : array();

$success = $this->_set_registration_status( $REG_ID, $status );

//notify
if ( $success && $notify && EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'espresso_registrations_resend_registration' ) ) {
$this->_process_resend_registration();
}

return $success;
}

But I d’on’t know how to call it from my template. I guess I have to instantiate something.
And I d’ont know what do EE4 need in “$this”.

I try something, but its not working

	$registrations = EEM_Registration::instance()->get_all( array( array( 'REG_ID' => array( 'IN', $REG_IDs ) ) ) );
	$result = ! empty( $STS_ID ) ? $registrations->_set_registration_status_from_request( $STS_ID, true ) : array( 'success' => false );

Thanks a lot for your help.


JacquesMivi

May 8, 2016 at 9:27 am

I find a solution using this function

function update_attendee($REG_ID, $STS_ID) {

	$success = true;
	$registration = EEM_Registration::instance()->get_one_by_ID( $REG_ID );
	if ( $registration instanceof EE_Registration ) {
		$registration->set_status( $STS_ID, false);
		$result = $registration->save();
		
		//verifying explicit fails because update *may* just return 0 for 0 rows affected
		$success = $success !== false && $result !== false;
		if ( $success ) {
			EED_Messages::process_resend( array( '_REG_ID' => $REG_ID ));
		}
	}
	return $result;			
}

It’s work.
But if you have idea to improve it, i take it.
Thanks.


Josh

  • Support Staff

May 11, 2016 at 7:32 pm

It might not be a bad idea to prefix that function name.

The support post ‘Change statut & notification in front’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso