Since it can be somewhat difficult to understand what zSSkitzz has written, here again in simpler terms. Create a function.
UFUNCTION()
void beginPlay(UWorld* world);
Then in the constructor or somewhere else bind the function to the event.
FWorldDelegates::OnPostWorldCreation.AddUObject(this, &UMyClass::beginPlay);